如何使用 Get-MgGroup 获取 Microsoft Entra ID 组

检索 Microsoft Entra ID 组

Microsoft Entra ID 组在管理组织内的用户访问权限和安全性方面起着关键作用。IT 管理员通常需要检索这些组以维护适当的访问控制并简化身份管理。虽然 Microsoft Graph 中的 Get-MgGroup 等 PowerShell 命令可以帮助获取 Microsoft Entra ID 组及其详细信息,但它们需要大量脚本编写和手动操作。

另外,像 ManageEngine ADManager Plus 这样的工具可以通过用户友好、无代码的界面简化此过程。借助内置的 reportsmanagement templates,管理员可以轻松检索、管理并监控他们的 Microsoft Entra ID 组,无需编写任何脚本。

  • ADManager Plus
  • PowerShell
 

使用 ADManager Plus 获取 Microsoft Entra ID 组

  1. 登录 ADManager Plus,导航至 Microsoft 365 > Reports > Group Reports
  2. 在 General Group Reports 下,选择 All Groups 报告。
  3. 从相应的下拉菜单中选择所需的 Microsoft 365 TenantDomains
  4. 点击 Generate Now
使用 ADManager Plus 的综合报告获取 Microsoft Entra ID 组。
 
 

以多种格式导出报告,如 PDF、XLS、CSV 和 HTML。

 
 

展开并导出图表。

 
 

设置自动报告生成。

使用 Microsoft Graph PowerShell 获取 Microsoft Entra ID 组

前提条件

在运行 Get-MgGroup 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-MgGroup cmdlet 获取 Microsoft Entra ID 组

使用 Microsoft Graph PowerShell 中的 Get-MgGroup cmdlet 来检索 Microsoft Entra ID 组。语法如下:

Get -MgGroup
[-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-MgGroup cmdlet 的示例用例和脚本

示例 1:通过显示名称获取组

使用此 Graph PowerShell 命令通过显示名称检索 Microsoft Entra ID 组。

Get-MgGroup -Filter "DisplayName eq 'GroupName'"

示例 2:获取所有组的列表

使用此 Graph PowerShell 命令检索组织中所有 Microsoft Entra ID 组的列表。

Get-MgGroup | Format-List Id, DisplayName, Description, GroupTypes

示例 3:获取所有组的数量

使用此 Graph PowerShell 命令检索组织中所有 Microsoft Entra ID 组的数量。

Get-MgGroup -ConsistencyLevel eventual -Count groupCount

支持的参数

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

参数 描述
-All 此列表显示所有页面。
-ConsistencyLevel 这表示请求的一致性级别。
-CountVariable 指定集合中项目的总数。默认情况下,此变量将在全局作用域中设置。
-Search 通过搜索短语搜索项目。
-Filter 按属性值过滤项目。
-GroupID 这是组的唯一标识符。

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

  • IT 管理员必须从 Azure AD PowerShell 升级,并且熟练掌握 PowerShell 脚本编写。
  • Microsoft Graph API 的限制可能会影响检索大量用户数据时的性能。
  • 可能需要额外的工作来格式化和导出数据以用于报告和审计。
  • 缺乏直观的界面使其对新手脚本用户不够友好。
  • 频繁的 API 更新可能需要修改脚本以保持兼容性。

使用 ADManager Plus 获取 Microsoft Entra ID 组的亮点

  • ADManager Plus 提供数百个预构建的 easy-to-generate reports。
  • 自定义这些报告并 schedule them 以实现自动报告生成。
  • 通过生成的报告直接执行即时操作,轻松管理用户。
  • these reports 导出为多种格式,如 HTML、CSV、XLS 和 PDF。
  • 内置批量用户和组管理操作,免去复杂的 Graph PowerShell 脚本编写。

使用 ADManager Plus 轻松获取 Microsoft Entra ID 组详细信息

 
  • 检索 Microsoft Entra ID 组
  • 使用 ADManager Plus 获取 Microsoft Entra ID 组
  • 使用 Microsoft Graph PowerShell 获取 Microsoft Entra ID 组
  • 使用 Graph PowerShell 脚本检索 Microsoft Entra ID 组的挑战
  • 使用 ADManager Plus 获取 Microsoft Entra ID 组的亮点
Active Directory管理与报告的一站式解决方案
电子邮件下载链接 Email the ADManager Plus download link