Get-MgGroupCount

What is Get-MgGroupCount?

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.


Why Use Get-MgGroupCount?

This cmdlet is useful for automation and reporting, especially when you need to:

  • Monitor group growth trends.
  • Audit the number of security or Microsoft 365 (Unified) groups.
  • Include group count statistics in automated reports or scripts.

It’s far more efficient than retrieving full group objects when you only need counts.


Prerequisites

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"

How to Use Get-MgGroupCount?

Basic syntax for the cmdlet:

Get-MgGroupCount [-ConsistencyLevel <String>]

The -ConsistencyLevel parameter ensures accurate counting across large datasets by using eventual consistency.


Get-MgGroupCount Examples

Example 1: Retrieve the Total Count of All Groups

This example retrieves the total number of Microsoft 365 groups in your tenant.

Get-MgGroupCount -ConsistencyLevel Eventual

Example 2: Retrieve Group Count Based on Filter Criteria

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

Summary

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