A cloud-based identity and access management service for securing user authentication and resource access
The portal check list can show all green and still fail tenant deletion because of enterprise applications (service principals) that can’t be removed from the UI. These must be cleaned up with PowerShell before the tenant can be deleted.
Use this end‑to‑end procedure:
- Install required PowerShell modules
Install-Module Microsoft.Graph
Install-Module -Name Az
- Connect explicitly to the tenant that must be deleted
Use a Global Administrator that is homed in this tenant (not a guest account).
Connect-MgGraph -Scopes "Application.ReadWrite.All"
Get-MgDomain # verify the onmicrosoft.com domain and tenant ID
Clear-AzContext -Scope CurrentUser
Connect-AzAccount -Tenant <object id of the tenant you are attempting to delete>
Get-AzContext # confirm the same tenant ID/onmicrosoft.com domain
These checks ensure that subsequent commands run only against the tenant that is being removed.
- Remove all enterprise applications (service principals)
Some service principals are not deletable from the portal but can be removed through Microsoft Graph. Run this command; execute it multiple times until it no longer finds removable objects (some deletions fail on first attempt because of dependencies):
Get-MgServicePrincipal -All | ForEach-Object {
Remove-MgServicePrincipal -ServicePrincipalId $_.Id
}
- Disable and retry removal for stubborn service principals
If any service principals still cannot be deleted, first disable them, then try deletion again:
$ServicePrincipalUpdate = @{ "accountEnabled" = "false" }
Get-MgServicePrincipal -All | ForEach-Object {
Update-MgServicePrincipal -ServicePrincipalId $_.Id -BodyParameter $ServicePrincipalUpdate
}
Get-MgServicePrincipal -All | ForEach-Object {
Remove-MgServicePrincipal -ServicePrincipalId $_.Id
}
Disabling them prevents them from blocking the tenant deletion even if some remain.
- Delete the tenant again from the portal
- Sign in to the Microsoft Entra admin center as Global Administrator.
- Go to Microsoft Entra ID → Overview → Manage tenants.
- Select the tenant and choose Delete.
- If all checks are still green, confirm Delete.
This sequence specifically addresses the known issue mentioned in the notification: enterprise apps that cannot be deleted in the portal but can be removed or disabled using Microsoft Graph PowerShell, after which tenant deletion succeeds.
References: