我当前正在尝试获取可与 Azure AD 中给定组关联的所有角色。到目前为止,我已经成功使用 Get-MgRoleManagementDirectoryRoleAssignment 命令。但问题是该命令仅向我提供“活动分配”选项卡中的角色。有没有办法让我能够收集“合格作业”选项卡的值?
我创建了一个由我拥有的组填充的数组,给定了它们的名称和 objectId,然后我只是运行这个 foreach 循环:
foreach($group in $groups){
$objectId= $group.ObjectId
$RoleAssignments = Get-MgRoleManagementDirectoryRoleAssignment -Filter "PrincipalId eq '$objectId'"
$allRoleAssignments= Get-MgRoleManagementDirectoryRoleAssignment
foreach($assignment in $RoleAssignments){
$roleDefinition = Get-MgRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId $assignment.RoleDefinitionId
Write-Output "Group Name: $($group.Name), Assigned Role Name: $($roleDefinition.DisplayName)"
}
}
所有这些都工作正常,但它只提供了活跃角色部分中的值。 我也尝试过使用 Graph API 进行检查,但到目前为止也没有显示任何相关内容。谢谢!
最初,我创建了安全组
Group02
,并将应用程序管理员分配为 Eligible Assignment
角色。
注意:对于合格的分配,使用
roleEligibilityScheduleInstances
。
使用下面的图形查询:
GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilityScheduleInstances?$filter=principalId eq '<GroupObjectId>'&$expand=roleDefinition
使用以下 Powershell 命令:
Import-Module Microsoft.Graph.Identity.Governance
Get-MgRoleManagementDirectoryRoleEligibilityScheduleInstance -Filter "principalId eq '<group object id>'" -ExpandProperty "roleDefinition"
参考: