如何获取Azure中具有权限的用户列表?

时间:2019-11-06 08:42:13

标签: azure azure-active-directory azure-powershell

我们正在尝试创建一个报告,其中应包含该人的全名,用户的电子邮件地址,Azure订阅名称,资源组名称和Azure角色。

使用此脚本:

Get-AzResourceGroup | ForEach-Object {
   Get-AzRoleAssignment -ResourceGroupName $_.ResourceGroupName | Where-Object { -not $_.Scope.Contains("managementGroups") -and $_.ObjectType -ne "ServicePrincipal" | Select-Object DisplayName } 
}

我们尝试获取用户列表,但未获取用户名及其权限

如何进行?

1 个答案:

答案 0 :(得分:0)

上面的代码段提供了具有以下属性的输出,这些属性在 PSRoleAssignment 类的Properties中进行了详细说明:

RoleAssignmentId
Scope
DisplayName
SignInName
RoleDefinitionName
RoleDefinitionId
ObjectId
ObjectType
CanDelegate

其中DisplayName映射到用户的全名,SignInName映射到他/她的电子邮件地址,Scope包含Azure订阅ID,而RoleDefinitionName映射到用户的角色。

如果要自定义输出中的属性,请考虑使用PSCustomObject。查看this文章以供参考。