Last active
February 1, 2021 18:47
-
-
Save ranieuwe/0641322cfc419cbba32231a4013924f0 to your computer and use it in GitHub Desktop.
Delete all AAD service principals and enterprise app registrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a quick way to delete all enterprise applications when you want to delete | |
# an AAD tenant in some cases some of the Enterprise Apps have dangling service principals | |
# that are hard to see. | |
# This script iterates over all the principals and tries delete what it can so that that | |
# the tenant can be deleted. You will see warnings as some service principals can not | |
# be deleted. This is fine. | |
## WARNING --- WARNING -- MAKE SURE TO RUN THIS ON THE CORRECT TENANT --- WARNING --- WARNING | |
Connect-AzureAD -AccountId <USERNAME>@<TENANT>.onmicrosoft.com | |
Get-AzureADServicePrincipal | ForEach({ Remove-AzureADServicePrincipal -ObjectId $_.objectid }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment