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.
Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.
Get-MgGroupMemberCountAsUser -GroupId <String>-ConsistencyLevel <String>
Key parameter:
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.
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.
| 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. |
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.
© m365corner.com. All Rights Reserved. Design by HTML Codex