55 [string ] $tenantId
66)
77
8- if ((Get-Module - ListAvailable - Name " AzureAD" ) -eq $null ) {
8+ if ($null -eq (Get-Module - ListAvailable - Name " AzureAD" )) {
99 Install-Module " AzureAD" - Scope CurrentUser
1010}
1111Import-Module AzureAD
@@ -44,7 +44,7 @@ This function removes the Azure AD applications for the sample. These applicatio
4444 $tenantId = $creds.Tenant.Id
4545 }
4646 $tenant = Get-AzureADTenantDetail
47- $tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name
47+ $tenantName = ($tenant.VerifiedDomains | Where-Object { $_._Default -eq $True }).Name
4848
4949 # Removes the applications
5050 Write-Host " Cleaning-up applications from tenant '$tenantName '"
@@ -56,19 +56,31 @@ This function removes the Azure AD applications for the sample. These applicatio
5656 {
5757 Remove-AzureADApplication - ObjectId $apps.ObjectId
5858 }
59- # Get-AzureRmADServicePrincipal -SearchString "TodoListService-ManualJwt" | ForEach-Object {Remove-AzureRmADServicePrincipal -ObjectId $_.Id -Confirm:$false}
60- Write-Host " Removed TodoListService-ManualJwt."
6159
60+ foreach ($app in $apps )
61+ {
62+ Remove-AzureADApplication - ObjectId $app.ObjectId
63+ Write-Host " Removed TodoListService-ManualJwt.."
64+ }
65+ # also remove service principals of this app
66+ Get-AzureADServicePrincipal - filter " DisplayName eq 'TodoListService-ManualJwt'" | ForEach-Object {Remove-AzureADServicePrincipal - ObjectId $_.Id - Confirm:$false }
67+
6268 Write-Host " Removing 'client' (TodoListClient-ManualJwt) if needed"
6369 Get-AzureADApplication - Filter " DisplayName eq 'TodoListClient-ManualJwt'" | ForEach-Object {Remove-AzureADApplication - ObjectId $_.ObjectId }
6470 $apps = Get-AzureADApplication - Filter " DisplayName eq 'TodoListClient-ManualJwt'"
6571 if ($apps )
6672 {
6773 Remove-AzureADApplication - ObjectId $apps.ObjectId
6874 }
69- # Get-AzureRmADServicePrincipal -SearchString "TodoListClient-ManualJwt" | ForEach-Object {Remove-AzureRmADServicePrincipal -ObjectId $_.Id -Confirm:$false}
70- Write-Host " Removed TodoListClient-ManualJwt."
7175
76+ foreach ($app in $apps )
77+ {
78+ Remove-AzureADApplication - ObjectId $app.ObjectId
79+ Write-Host " Removed TodoListClient-ManualJwt.."
80+ }
81+ # also remove service principals of this app
82+ Get-AzureADServicePrincipal - filter " DisplayName eq 'TodoListClient-ManualJwt'" | ForEach-Object {Remove-AzureADServicePrincipal - ObjectId $_.Id - Confirm:$false }
83+
7284}
7385
74- Cleanup - Credential $Credential - tenantId $TenantId
86+ Cleanup - Credential $Credential - tenantId $TenantId
0 commit comments