AAD Application Check

#Check for and/or creating AAD Application Write-Host -ForegroundColor Green "Checking for application '$aadAppName'" $azureAdApplicationValidation = Get-AzureRmADApplication -IdentifierUri "https://$aadAppName" if ($azureAdApplicationValidation -eq $null) { Write-Host -ForegroundColor Green "Application not found in AAD, creating application '$aadAppName'" $azureAdApplication = New-AzureRmADApplication -DisplayName "$aadAppName" -HomePage "https://$aadAppName" -IdentifierUris "https://$aadAppName" -Password $aadClientSecret -ErrorVariable errorck ErrorCheck $servicePrincipal = New-AzureRmADServicePrincipal –ApplicationId $azureAdApplication.ApplicationId -ErrorVariable errorck ErrorCheck } Else { Write-Host -ForegroundColor Yellow -BackgroundColor Black "Application '$aadAppName' found, adding key to existing application" $azureAdApplication = $azureAdApplicationValidation $hout = New-AzureRmADAppCredential -ApplicationId $azureAdApplication.ApplicationId.Guid -Password $aadClientSecret -ErrorVariable errorck ErrorCheck $servicePrincipal = Get-AzureRmADServicePrincipal -ServicePrincipalName $azureAdApplication.ApplicationId -ErrorVariable errorck if ($servicePrincipal -eq $null) { $servicePrincipal = New-AzureRmADServicePrincipal –ApplicationId $azureAdApplication.ApplicationId -ErrorVariable errorck ErrorCheck } }
24 lines of commands, a snippet from a working script. These lines check for and/or create an Azure Active Directory (AAD) Application.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.