如何使用 Get-MgGroupAppRoleAssignment 获取 Microsoft Entra ID 组的应用角色

检索 Microsoft Entra ID 组的应用角色

Microsoft Entra ID 中的应用角色分配有助于定义授予应用访问组资源的权限。IT 管理员通常需要检索这些分配,以有效监控和管理应用权限。Microsoft Graph 中的 PowerShell cmdlet,如 Get-MgGroupAppRoleAssignment,允许获取组的应用角色分配,但需要大量脚本编写和手动操作。

使用 Microsoft Graph PowerShell 获取 Microsoft Entra ID 组的应用角色

前提条件

在运行 Get-MgGroupAppRoleAssgnment cmdlet 之前,请确保满足以下要求:

  • The Microsoft Graph PowerShell module is installed. If it’s not installed, use the following command:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the required permissions to retrieve and manage Microsoft Entra ID groups:
    Connect-MgGraph -Scopes "Group.Read.All"

使用 Get-MgGroupAppRoleAssignment cmdlet 获取 Microsoft Entra ID 组的应用角色

使用 Microsoft Graph PowerShell 中的 Get-MgGroupAppRoleAssignment cmdlet 检索授予 Microsoft Entra ID 组的应用角色。语法如下:

Get-MgGroupAppRoleAssignment
-GroupId <String>
[-ExpandProperty <String[]>]
[-Property <String[]>]
[-Filter <String>]
[-Search <String>]
[-Skip <Int32>]
[-Sort <String[]>]
[-Top <Int32>]
[-ConsistencyLevel <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PageSize <Int32>]
[-All]
[-CountVariable <String>]
[-ProgressAction <ActionPreference>]
[<CommonParameters>]

使用 Get-MgGroupAppRoleAssignment cmdlet 的示例用例和脚本

示例:获取授予某组的应用角色分配

Get-MgGroupAppRoleAssignment -GroupId "<Your-Group-ID>"

支持的参数

下表列出了可与 Get-MgGroupAppRoleAssignment cmdlet 一起使用的关键参数,以高效检索授予 Microsoft Entra ID 组的应用角色。

参数 描述
-All 此列表显示所有页面。
-AppRoleAssignmentId 这是 AppRoleAssignment 对象的唯一标识符。
-ConsistencyLevel 这表示请求的一致性级别。
-CountVariable 这指定集合中项目的总数。
-Filter 按属性值过滤项目。

注意:Microsoft 已宣布弃用 Azure AD PowerShell 并过渡到 Microsoft Graph PowerShell。

使用 Graph PowerShell 脚本检索 Microsoft Entra ID 组的应用角色的挑战

  • Microsoft Graph API 有速率限制,可能导致批量用户检索延迟并影响效率。
  • 缺乏用户友好的图形界面,使得脚本经验有限的用户难以操作。
  • 内置报告功能有限,需要自定义脚本以获得全面洞察。
  • 导出数据进行报告通常涉及额外的脚本工作。

为什么使用 ADManager Plus 进行管理和报告?

使用 ADManager Plus 监控您的 Microsoft Entra ID 用户和组

 
  • 检索 Microsoft Entra ID 组的应用角色
  • 使用 Microsoft Graph PowerShell 获取 Microsoft Entra ID 组的应用角色
  • 使用 Graph PowerShell 脚本检索 Microsoft Entra ID 组的应用角色的挑战
  • 为什么使用 ADManager Plus 进行管理和报告?
Active Directory管理与报告的一站式解决方案
电子邮件下载链接 Email the ADManager Plus download link