我正在尝试找到一种方法,利用json文件通过Powershell更新Azure广告注册的应用程序的清单。
Json文件包含所有应用程序角色,我想简单地将应用程序角色注入[]到应用程序角色括号中
有没有办法通过电源外壳或CLI来实现此目的?
是的,您可以通过PowerShell更新Azure AD应用程序的清单。
特别是为了添加应用程序角色,这是一个PowerShell脚本。
如果您在创建新应用程序时尝试执行此操作,请使用New-AzureADApplication代替Set-AzureADApplication。
New-AzureADApplication
Set-AzureADApplication
Connect-AzureAD -TenantId <Tenant GUID> # Create an application role of given name and description Function CreateAppRole([string] $Name, [string] $Description) { $appRole = New-Object Microsoft.Open.AzureAD.Model.AppRole $appRole.AllowedMemberTypes = New-Object System.Collections.Generic.List[string] $appRole.AllowedMemberTypes.Add("User"); $appRole.DisplayName = $Name $appRole.Id = New-Guid $appRole.IsEnabled = $true $appRole.Description = $Description $appRole.Value = $Name; return $appRole } # ObjectId for application from App Registrations in your AzureAD $appObjectId = "<Your Application Object Id>" $app = Get-AzureADApplication -ObjectId $appObjectId $appRoles = $app.AppRoles Write-Host "App Roles before addition of new role.." Write-Host $appRoles $newRole = CreateAppRole -Name "MyNewApplicationRole" -Description "This is my new Application Role" $appRoles.Add($newRole) Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $appRoles