The Get-MgGroupCount cmdlet in Microsoft Graph PowerShell retrieves the total number of Microsoft 365 groups within your organization. It helps administrators quickly obtain the group count without listing all group details.
This cmdlet is useful for automation and reporting, especially when you need to:
It’s far more efficient than retrieving full group objects when you only need counts.
Before running this cmdlet, ensure you have the Microsoft Graph module installed and the required permissions:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Group.Read.All"
Basic syntax for the cmdlet:
Get-MgGroupCount [-ConsistencyLevel <String>]
The -ConsistencyLevel parameter ensures accurate counting across large datasets by using eventual consistency.
This example retrieves the total number of Microsoft 365 groups in your tenant.
Get-MgGroupCount -ConsistencyLevel Eventual
You can apply filters to count only specific types of groups, such as Office 365 (Unified) groups.
Get-MgGroupCount -Filter "groupTypes/any(c:c eq 'Unified')" -ConsistencyLevel Eventual
| Key Point | Details |
|---|---|
| Cmdlet Name | Get-MgGroupCount |
| Purpose | Retrieves the count of Microsoft 365 groups in the tenant |
| Required Scope | Group.Read.All |
| Primary Parameter | ConsistencyLevel, Filter |
| Automation Benefit | Enables admins to automate reporting and monitoring of group statistics |
| Use Case | Tracking growth or auditing group usage in Microsoft 365 |
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