Unable to delete M365 Tenant do to existing “Enterprise Applications.”

Problem Description

You may find yourself in the process of deleting a Microsoft 365 Tenant because you’re no longer using it or would like to make the domain name available for reuse.

However, when attempting to “Delete all enterprise applications“, you are not able to proceed with error, “You can’t delete this application because it’s a Microsoft first party application.”

Example:

Cause

This is a common issue where the installed “Enterprise Application” that is preventing the Tenant deletion is not exposed to the “Enterprise Applications” list in the Azure Admin Portal.

Resolution

The resolution is simple if you are familiar with PowerShell and using the MSOnline or Azure modules.  To resolve the issue, execute one of the solutions provided below.

MSOnline Module:
1
2
3
4
5
6
#Install the MSOnline Module
Install-Module -Name MSOnline
#Connect and Sign into your Tenant with a Global Admin
connect-msolservice 
#Loop through and delete all Service Principals
Get-MsolServicePrincipal -All | Remove-MsolServicePrincipal
Azure Modules
1
2
3
4
5
6
7
#install AZ Modules
Install-Module -Name Az.Resources
Install-Module -Name Az.Accounts
#Connect and Sign into your Tenant with a Global Admin
Connect-AzAccount 
#Loop through and delete all Service Principals
Get-AzADServicePrincipal | ForEach-Object { Remove-AzADServicePrincipal -ObjectId $_.Id -Force}

Note: You may see errors from the PowerShell output while deleting the Service Principals, this is normal as its trying to delete objects that cannot be removed.

After the deletion script completes, you should now be able to delete your Tenant.

More information

Delete an Azure AD organization (tenant) – Azure Active Directory | Microsoft Docs

Troubleshoot common problems adding or removing an application to Azure Active Directory – Active Directory | Microsoft Docs

Az.Accounts Module | Microsoft Docs

Az.Accounts Module | Microsoft Docs

Leave a Reply