How to delete Microsoft Entra ID groups using Remove-MgGroup

Deleting Microsoft Entra ID groups

Deleting Microsoft Entra ID groups is a critical task for IT administrators to maintain a clean and secure directory, ensuring that obsolete or unnecessary groups do not pose any security risks. Whether decommissioning unused groups or enforcing governance policies, admins need an efficient way to manage the removal of groups. While the Remove-MgGroup PowerShell command in Microsoft Graph allows for group removal, it requires long scripts and is time-consuming.

For a more efficient and user-friendly approach, ManageEngine ADManager Plus offers the ideal solution. With its user-friendly interface, administrators can easily identify, review, and delete Microsoft Entra ID groups in bulk—ensuring seamless directory management without the need for complex PowerShell scripts.

  • ADManager Plus
  • PowerShell
 

Delete Microsoft Entra ID groups using ADManager Plus

  1. Log in to ADManager Plus and go to Microsoft 365 > Management > Group Management.
  2. Under Bulk Group Modification, select Delete Groups.
  3. Select the Microsoft 365 Tenant from which to delete groups.
  4. Now, you can either manually select the groups by entering their names or import them in bulk using a CSV file.
  5. Click Find.
  6. Select the groups you want to delete from the displayed list, or choose all if needed.
  7. Then, click Apply.
Delete Microsoft Entra ID groups using ADManager Plus' built-in management actions.
 
 

Select the Microsoft 365 tenant.

 
 

Import the list of groups with a CSV file.

Delete Microsoft Entra ID groups in bulk using ADManager Plus.
 
 

Select the desired Microsoft Entra ID groups to be deleted.

Delete Microsoft Entra ID groups using Microsoft Graph PowerShell

Prerequisites

Before running the Remove-MgGroup cmdlet, ensure the following requirements are met:

  • 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 manage and delete Microsoft Entra ID groups:
    Connect-MgGraph -Scopes "Group.ReadWrite.All"

Using the Remove-MgGroup cmdlet to delete Microsoft Entra ID groups

Use the Remove-MgGroup cmdlet in Microsoft Graph PowerShell to delete Microsoft Entra ID groups. The syntax is as follows:

Remove-MgGroup
-GroupId <String>
[-IfMatch <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PassThru]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

Example use case and script using the Remove-MgGroup cmdlet

Example: Remove a Microsoft Entra ID group

Use this Graph PowerShell command to delete a Microsoft Entra ID group.

Remove-MgGroup -GroupId 'f6b9791b-dfc1-40d6-9ab6-7b29126c534a'

Supported parameters

The table below lists key parameters that can be used with the Remove-MgGroup cmdlet to delete Microsoft Entra ID groups.

Parameters Description
-GroupId This is the unique identifier of the group.
-Headers This is for optional headers that will be added to the request.
-Confirm This prompts the admin to confirm before running the cmdlet.
-WhatIf This shows what would happen if the cmdlet was run. The cmdlet is not actually run.

Challenges of using Graph PowerShell scripts to delete Microsoft Entra ID groups

  • Assigning roles and permissions can be tricky since some commands require special privileges.
  • Microsoft’s API rate throttling limits can interrupt bulk operations, requiring retries.
  • Some Microsoft Graph features lack PowerShell cmdlets and require manual API calls.
  • Admins need strong PowerShell skills to switch from Azure AD to Microsoft Graph PowerShell.

Highlights of using ADManager Plus to delete Microsoft Entra ID groups

ADManager Plus can make your Microsoft Entra ID group management hassle-free

 
  • Deleting Microsoft Entra ID groups
  • Delete Microsoft Entra ID groups using ADManager Plus
  • Delete Microsoft Entra ID groups using Microsoft Graph PowerShell
  • Challenges of using Graph PowerShell scripts to delete Microsoft Entra ID groups
  • Highlights of using ADManager Plus to delete Microsoft Entra ID groups
The one-stop solution to Active Directory Management and Reporting
Email Download Link