Skip to content

Commit 0235294

Browse files
authored
Merge pull request #71 from Azure-Samples/bogavril/fixcleanup
Fix multiple apps with the same name cannot be deleted
2 parents a0bd598 + 9aab6ee commit 0235294

File tree

1 file changed

+8
-7
lines changed
  • 1. Desktop app calls Web API/AppCreationScripts

1 file changed

+8
-7
lines changed

1. Desktop app calls Web API/AppCreationScripts/Cleanup.ps1

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ param(
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
}
1111
Import-Module AzureAD
@@ -44,27 +44,28 @@ 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'"
5151

5252
Write-Host "Removing 'service' (TodoListService (active-directory-dotnet-native-aspnetcore-v2)) if needed"
53-
$app=Get-AzureADApplication -Filter "DisplayName eq 'TodoListService (active-directory-dotnet-native-aspnetcore-v2)'"
53+
$apps=Get-AzureADApplication -Filter "DisplayName eq 'TodoListService (active-directory-dotnet-native-aspnetcore-v2)'"
5454

55-
if ($app)
55+
foreach ($app in $apps)
5656
{
5757
Remove-AzureADApplication -ObjectId $app.ObjectId
5858
Write-Host "Removed TodoListService (active-directory-dotnet-native-aspnetcore-v2)."
5959
}
60+
6061
Write-Host "Removing 'client' (TodoListClient (active-directory-dotnet-native-aspnetcore-v2)) if needed"
61-
$app=Get-AzureADApplication -Filter "DisplayName eq 'TodoListClient (active-directory-dotnet-native-aspnetcore-v2)'"
62+
$apps=Get-AzureADApplication -Filter "DisplayName eq 'TodoListClient (active-directory-dotnet-native-aspnetcore-v2)'"
6263

63-
if ($app)
64+
foreach ($app in $apps)
6465
{
6566
Remove-AzureADApplication -ObjectId $app.ObjectId
6667
Write-Host "Removed TodoListClient (active-directory-dotnet-native-aspnetcore-v2)."
6768
}
68-
}
69+
}
6970

7071
Cleanup -Credential $Credential -tenantId $TenantId

0 commit comments

Comments
 (0)