Как удалить identifierUris с помощью PowerShell в приложении Azure Active Directory - PullRequest
0 голосов
/ 16 мая 2019

Я следую этой статье 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 перед созданием приложения

1 Ответ

1 голос
/ 22 мая 2019

Вы можете использовать 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
}
...