如何使用 Remove-MgGroupMemberByRef 删除 Microsoft Entra ID 组成员

删除 Microsoft Entra ID 组成员

管理 Microsoft Entra ID 组成员身份对于维护组织内的适当访问控制和安全至关重要。IT 管理员经常需要从组中移除特定用户或设备以撤销访问权限或执行策略更改。虽然 Microsoft Graph 中的 Remove-MgGroupMemberByRef PowerShell 命令允许管理员使用直接引用删除组成员,但这需要脚本编写技能和手动执行。

为了更高效且用户友好的方法,ManageEngine ADManager Plus 是一款具备全面 Microsoft Entra ID 管理和报告功能的身份治理与管理解决方案,提供无代码解决方案。借助其直观的界面和强大的管理操作,管理员可以无缝地从 Microsoft Entra ID 组中移除用户,执行访问策略并维护安全性,无需复杂的 PowerShell 脚本。

  • ADManager Plus
  • PowerShell
 

使用 ADManager Plus 删除 Microsoft Entra ID 组成员

  1. 登录 ADManager Plus。
  2. 导航至 Microsoft 365 > 管理 > 组管理
  3. 组成员管理 中,选择 使用 CSV 添加/删除组成员
  4. 从下拉菜单中选择所需的 Microsoft 365 Tenant
  5. 使用 CSV 导入 导入您想要修改的组或成员。
  6. 点击 导入组/成员
  7. 从 CSV 文件导入的组/成员数据 页面,选择您想要删除的成员并点击 应用
使用 ADManager Plus 报告删除 Microsoft Entra ID 组成员。
 
 

查看 CSV 文件中可指定的支持的 LDAP 头。

 
 

导入包含所需数据的 CSV 文件。

使用 Microsoft Graph PowerShell 删除 Microsoft Entra ID 组成员

前提条件

在运行 Remove-MgGroupMemberByRef 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 necessary permissions to manage group memberships:
    Connect-MgGraph -Scopes "GroupMember.ReadWrite.All"

使用 Remove-MgGroupMemberByRef cmdlet 删除 Microsoft Entra ID 组成员

使用 Microsoft Graph PowerShell 中的 Remove-MgGroupMemberByRef cmdlet 删除 Microsoft Entra ID 组成员。语法如下:

Remove-MgGroupMemberByRef
-InputObject <IGroupsIdentity>
[-IfMatch <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PassThru]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

使用 Remove-MgGroupMemberByRef cmdlet 的示例用例和脚本

示例:删除组成员

使用此 Graph PowerShell 命令从 Microsoft Entra ID 组中移除成员。

Import-Module Microsoft.Graph.Groups
Remove-MgGroupMemberByRef -GroupId $groupId -DirectoryObjectId $directoryObjectId

支持的参数

下表列出了可与 Remove-MgGroupMemberByRef cmdlet 一起使用以删除 Microsoft Entra ID 组成员的关键参数。

参数 描述
-Confirm 运行 cmdlet 前请确认此项。
-DirectoryObjectId 这是目录对象的唯一标识符。
-GroupId 这是组的唯一标识符。
-WhatIf 这显示如果运行该 cmdlet 会发生什么。

使用 Graph PowerShell 脚本删除 Microsoft Entra ID 组成员的挑战

  • IT 管理员需要从 Azure AD PowerShell 切换到 Graph PowerShell,这需要 PowerShell 脚本知识。
  • Microsoft Graph API 有限制速率,可能会减慢批量数据检索速度。
  • 调试错误可能具有挑战性且耗时,需要技术技能。
  • 缺乏用户友好的界面使其难以使用,尤其是对新手脚本用户。

使用 ADManager Plus 删除 Microsoft Entra ID 组成员的亮点

  • ADManager Plus 提供 内置管理操作,帮助管理员执行各种 Microsoft 365 任务。
  • 轻松执行 批量管理操作,无需任何复杂脚本。
  • 创建、删除和管理 Microsoft Entra ID 组,无需复杂的 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