Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitManaging groups in Microsoft 365 is a vital part of administration, especially when you’re dealing with hundreds or thousands of users. Whether you’re organizing distribution lists, managing Microsoft Teams, or handling security permissions, groups play a central role in how information and collaboration flow across your tenant.
The Get-MgGroup cmdlet from Microsoft Graph PowerShell makes it easy to retrieve, search, and filter groups efficiently — all from your PowerShell console.
The Get-MgGroup cmdlet retrieves information about Microsoft 365 groups (also called Microsoft Entra groups) from your tenant using Microsoft Graph PowerShell.
With it, you can:
Whether you’re an IT admin or a PowerShell enthusiast, this cmdlet gives you quick access to everything you need to manage your groups efficiently.
Microsoft is gradually replacing older PowerShell modules like MSOnline and AzureAD with the Microsoft Graph PowerShell module.
Here’s why you should switch to Get-MgGroup:
Here’s the basic syntax of the cmdlet:
Get-MgGroup -GroupId "<group-id>"
| Parameter | Description |
|---|---|
| -GroupId | Specifies the group to retrieve by its unique ID. |
| -All | Retrieves all groups from the tenant. |
| -Filter | Allows you to narrow results using OData filters (e.g., DisplayName eq 'Marketing'). |
| -Search | Lets you search for groups containing a specific string in their name. |
| -Property | Retrieves specific properties of the group. |
Get-MgGroup -GroupId "5b34b8a4-6e77-4d8a-94eb-9b150d938f97"
This example retrieves details of a group specified by its ID.
Get-MgGroup -All
This example retrieves all groups in the organization.
Get-MgGroup -Filter "DisplayName eq 'Marketing'"
This example retrieves groups with the display name “Marketing.”
Get-MgGroup -All -Property Id, DisplayName, GroupTypes
This example retrieves all groups and displays only the Id, DisplayName, and GroupTypes properties.
Get-MgGroup -Search "displayName:Project"
This example searches for groups whose display names contain the string “Project.”
(Get-MgGroup -All).Count
This example retrieves the total number of groups in the organization.
Get-MgGroup -All | Select-Object DisplayName, CreatedDateTime | Sort-Object CreatedDateTime
This example retrieves the names and creation dates of all groups and sorts them by the creation date.
Let’s look at two practical examples where Get-MgGroup can make real administrative tasks faster and easier.
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Group.Read.All"
# Retrieve only Unified (Microsoft 365) groups
$UnifiedGroups = Get-MgGroup -All | Where-Object {
$_.GroupTypes -contains "Unified"
}
# Display the results
$UnifiedGroups | Select DisplayName, Mail, Visibility, CreatedDateTime
🔍 Note: Unified groups power Microsoft Teams, Planner, and SharePoint collaboration workspaces, so this script is particularly useful for M365 group audits.
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Group.Read.All"
# Retrieve only distribution lists (mail-enabled, NOT security or unified groups)
$distributionLists = Get-MgGroup -All | Where-Object {
$_.MailEnabled -eq $true -and
$_.SecurityEnabled -eq $false -and
($_.GroupTypes -eq $null -or $_.GroupTypes.Count -eq 0)
}
# Output results
$distributionLists | Select DisplayName, Mail, Id
💡 Tip: You can export the results to CSV using Export-Csv for reporting.
The Get-MgGroup cmdlet is a must-have tool in every Microsoft 365 administrator’s toolkit. It gives you instant visibility into your organization’s group structure — whether it’s Microsoft 365, distribution, or security groups.
With examples like filtering groups, fetching creation dates, and listing Unified or Distribution groups, you can streamline reporting and automate repetitive group management tasks.
🚀 Pro Tip: Combine Get-MgGroup with cmdlets like Get-MgGroupMember and Get-MgGroupOwner to build advanced reports and get a complete view of group ownership and membership.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex