Quick win 1: How to Delete your Azure AD Tenant programmatically ?

Itsmem0h1t
Nov 2, 2020

--

In case you are struggling to delete your Azure Ad tenant and while doing so from the Azure portal it gives you an error ‘delete your enterprise apps’ which you have already deleted in the first place. go through these steps :)

Ingredients you require — Global administrator (create a new user if required with this role)

follow these steps -

1. If the Global Administrator of the tenant is guest/external user, please create a new user and assign it with Global Administrator role (If the current user is part of other tenant, the cmdlets might affect other applications).

2. Run PowerShell as administrator

3. Install-Module MSOnline (follow the prompts to install the module if not installed already)

4. Connect-MsolService please login with the new Global Administrator

5. Get-MsolServicePrincipal | Remove-MsolServicePrincipal This will clear all Service Principals
(so please be sure that you are connected to the right tenant with the account which is member for this tenant only, before run the cmdlet).

Note: You may receive an error when you remove some service principals. These principals can’t be removed. However, this does not prevent you from deleting your directory. The error that you receive may resemble the following:

“Remove-MsolServicePrincipal : Invalid value for parameter. Parameter Name: appPrincipalId”

login to your portal and look for your tenant, it would be deleted!

Thanks!

--

--

Itsmem0h1t
Itsmem0h1t

Written by Itsmem0h1t

Program Architect at Salesforce, 27x Certified

No responses yet