我正在关注本文https://blogs.msdn.microsoft.com/azuresqldbsupport/2017/09/01/how-to-create-an-azure-ad-application-in-powershell/
使用Azure Active Directory Application
创建PowerShell
,但是失败,因为identifierUris
已经存在。
$appName = "yourappname123"
$uri = "http://yourappname123"
$secret = "yoursecret123"
$azureAdApplication = New-AzADApplication -DisplayName $appName -HomePage $Uri -IdentifierUris $Uri -Password $(ConvertTo-SecureString -String $secret -AsPlainText -Force)
是否可以在创建应用程序之前删除标识符,或者可以在创建应用程序之前进行验证检查是否存在identifierUri
答案 0 :(得分:1)
您可以将Get-AzADApplication与参数-IdentifierUri
一起使用,以测试是否已存在具有该IdentifierUri的应用程序:
$appName = "yourappname123"
$uri = "http://yourappname123"
$secret = "yoursecret123"
$password = ConvertTo-SecureString -String $secret -AsPlainText -Force
# test if an app using that uri is already present
$app = (Get-AzADApplication -IdentifierUri $uri)
if ($app) {
Write-Warning "An app with identifier uri '$uri' already exists: '$($app.DisplayName)'"
# there already is an app that uses this identifier uri..
# decide what to do:
# - choose a new uri for the new app?
# - change the identifier uri on the existing app?
# you can do that using
# $app | Update-AzADApplication -IdentifierUri 'THE NEW URI FOR THIS APP'
}
else {
# all seems clear; create your new app
$azureAdApplication = New-AzADApplication -DisplayName $appName -HomePage $Uri -IdentifierUris $Uri -Password $password
}