Get-EntraDirectoryRole
获取目录角色。
语法
GetQuery (默认值)
Get-EntraDirectoryRole
[-Filter <String>]
[-Property <String[]>]
[<CommonParameters>]
GetById
Get-EntraDirectoryRole
-DirectoryRoleId <String>
[-Property <String[]>]
[<CommonParameters>]
说明
该 Get-EntraDirectoryRole cmdlet 从Microsoft Entra ID获取目录角色。 指定 ObjectId 参数以获取目录角色。
在工作或学校帐户的委派方案中,登录用户必须具有受支持的Microsoft Entra角色或具有必要权限的自定义角色。 此操作支持以下最低特权角色:
- 用户管理员
- 服务台管理员
- 服务支持管理员
- 计费管理员
- 目录读取器
- 目录编写人员
- 应用程序管理员
- 安全阅读器
- 安全管理员
- 特权角色管理员
- 云应用程序管理员
示例
示例 1:按 ID 获取目录角色
Connect-Entra -Scopes 'RoleManagement.Read.Directory'
$directoryRole = Get-EntraDirectoryRole -Filter "displayName eq 'Helpdesk Administrator'"
Get-EntraDirectoryRole -DirectoryRoleId $directoryRole.Id
ObjectId DisplayName Description
-------- ----------- -----------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Helpdesk Administrator Company Administrator role has full access to perform any operation in the company scope.
此命令获取指定的目录角色。
-
-ObjectId参数指定Microsoft Entra ID中目录角色的 ID。
示例 2:获取所有目录角色
Connect-Entra -Scopes 'RoleManagement.Read.Directory'
Get-EntraDirectoryRole
DeletedDateTime Id Description
--------------- -- -----------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Perform all migration functionality to migrate content to Microsoft 365 usin...
aaaaaaaa-6666-7777-8888-bbbbbbbbbbbb Can manage all aspects of users and groups, including resetting passwords fo...
bbbbbbbb-7777-8888-9999-cccccccccccc Can read basic directory information. Commonly used to grant directory read ...
cccccccc-8888-9999-0000-dddddddddddd Can read and write basic directory information. For granting access to appli...
此命令获取所有目录角色。
示例 3:按 ID 获取目录角色筛选器
Connect-Entra -Scopes 'RoleManagement.Read.Directory'
Get-EntraDirectoryRole -Filter "Id eq 'c0e36062-8c80-4d72-9bc3-cbb4efe03c21'"
Id DisplayName Description
-------- ----------- -----------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Helpdesk Administrator Company Administrator role has full access to perform any operation in the company scope.
此命令按 ID 获取目录角色。
-
-Id参数指定Microsoft Entra ID中目录角色的 ID。
示例 4:按 displayName 获取目录角色筛选器
Connect-Entra -Scopes 'RoleManagement.Read.Directory'
Get-EntraDirectoryRole -Filter "displayName eq 'Helpdesk Administrator'"
DeletedDateTime Id Description
--------------- -- -----------
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb Can reset passwords for non-administrators and Helpdesk Administrators....
此命令按显示名称获取目录角色。
参数
-DirectoryRoleId
指定Microsoft Entra ID中目录角色的 ID。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 对象标识符 (ObjectId) |
参数集
GetById
| Position: | Named |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Filter
OData v4.0 筛选器语句。 控制返回的对象。
参数属性
| 类型: | System.String |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
GetQuery
| Position: | Named |
| 必需: | False |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | True |
| 来自剩余参数的值: | False |
-Property
指定要返回的属性
参数属性
| 类型: | System.String[] |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | Select |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。