将用户分配给企业应用程序 powershell

问题描述 投票:0回答:1

我对以下主题有疑问。我想向 Azure 中每个新创建的企业应用程序添加六个组。我已经有一个脚本来创建应用程序和我需要的其他任何东西...... 我只是努力添加六个组。也许你可以在这里帮助我?

问候马库斯

$GroupID = "****************" $app_name = "****************" $app_role_name = "Default Access"

# Get the group to assign $AADGROUP = Get-AzureADGroup -ObjectId $GroupID $sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'" $appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }

# Assign the group to the app role New-AzureADGroupAppRoleAssignment -ObjectId $AADGROUP.ObjectId -PrincipalId $AADGROUP.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id

这就是例子,但我不明白他们对这个角色的意思。 https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/assign-user-or-group-access-portal?pivots=portal

azure powershell automation azure-service-principal
1个回答
0
投票

注意:要将 Default Access 指定为应用程序角色,您需要将应用程序角色 ID 传递为

([Guid]::Empty)

要将组添加到具有默认访问权限的企业应用程序作为应用程序角色,请使用以下 PowerShell 脚本:

$app_name = "testrukk" $app_role_name = "Default Access" $groupIDs = @( "GroupID1", "GroupID2", "GroupID3", "GroupID4", "GroupID5", "GroupID6" ) $sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'" $appRole = ([Guid]::Empty) foreach ($groupID in $groupIDs) { $AADGROUP = Get-AzureADGroup -ObjectId $groupID if ($AADGROUP -ne $null) { New-AzureADGroupAppRoleAssignment -ObjectId $AADGROUP.ObjectId -PrincipalId $AADGROUP.ObjectId -ResourceId $sp.ObjectId -Id $appRole Write-Host "Assigned group $($AADGROUP.DisplayName) to application role." } else { Write-Host "Group with ID $groupID does not exist." } }

enter image description here

群组已成功添加到企业应用程序:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.