Get-MgGroupMemberCountAsUser: Graph PowerShell Cmdlet

In Microsoft Entra ID, group memberships can include users, devices, service principals, contacts, and even other groups. While listing members is useful, many scenarios—such as license planning, access reviews, or reporting—only require a count of user members, not a full member list.

The Get-MgGroupMemberCountAsUser cmdlet is designed for this exact purpose. It returns the count of direct user members in a group, excluding devices, service principals, contacts, and nested groups.

Important: This cmdlet requires the -ConsistencyLevel Eventual header to function.

🚀 Community Edition Released!

Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.

i) Cmdlet Syntax

Get-MgGroupMemberCountAsUser -GroupId <String>-ConsistencyLevel <String>

Key parameter:

  • -GroupId: The object ID of the Microsoft 365 or Entra ID group.
  • -ConsistencyLevel: Must be set to Eventual. This is mandatory for the cmdlet to return results.

ii) Usage Examples

Example 1: Passing GroupId when requested by the console

Get-MgGroupMemberCountAsUser

Explanation:
When run without parameters, the console prompts you to enter the GroupId. After providing it (and setting the required consistency level when prompted), the cmdlet returns the count of direct user members in the group.


Example 2: Passing GroupId directly with ConsistencyLevel

Get-MgGroupMemberCountAsUser  -GroupId efba43ca-ff99-4f70-b2c5-a97e9dbb75d2 `-ConsistencyLevel Eventual

Explanation:
This command directly returns the number of direct user members in the specified group, explicitly setting the required ConsistencyLevel header.


iii) Cmdlet Tips

  • -ConsistencyLevel Eventual is mandatory—the cmdlet will not work without it.
  • The cmdlet returns only a number, not user objects.
  • Counts direct user members only; users in nested groups are not included.
  • Non-user objects (devices, service principals, contacts, groups) are automatically excluded.
  • Ideal for quick reporting where performance matters more than detailed output.

iv) Possible Errors & Solutions

Error / Message Cause Solution
Request_UnsupportedQuery Missing consistency level Re-run the cmdlet with -ConsistencyLevel Eventual.
Authorization_RequestDenied Insufficient permissions Ensure Group.Read.All and User.Read.All are granted with admin consent.
Count returns 0 unexpectedly No direct user members Verify that users are not added via nested groups.
ResourceNotFound Invalid GroupId Confirm the group object ID in the Entra admin center.
Cmdlet not recognized Microsoft.Graph module missing Install or update using Install-Module Microsoft.Graph.

v) Conclusion

The Get-MgGroupMemberCountAsUser cmdlet provides a fast and efficient way to determine how many direct user members exist in a Microsoft 365 or Entra ID group. By filtering out non-user objects and requiring the -ConsistencyLevel Eventual header, it delivers an accurate user-only count—making it especially useful for audits, license planning, and lightweight reporting scenarios.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex