Get-MgGroupMemberAsUser is a Microsoft Graph PowerShell cmdlet used to retrieve only user objects that are direct members of a Microsoft 365 group, security group, or mail-enabled security group.
Unlike Get-MgGroupMember, which returns all directory object types (users, devices, service principals, contacts, nested groups), this cmdlet filters the output to return only users.
This makes it especially useful when you need clean, user-only membership data without additional filtering.
Try the M365Corner Microsoft 365 Reporting Tool â your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.
In many administrative scenarios, you only care about user accounts â not devices or service principals.
Common Scenarios
Using Get-MgGroupMemberAsUser:
For reporting-heavy environments, this cmdlet saves time and improves script clarity.
Before running this cmdlet:
Delegated Permissions
Application Permissions (For automation)
â ī¸ Admin consent is required for Directory-level permissions.
Install Microsoft Graph (If Needed)
Install-Module Microsoft.Graph -Scope CurrentUser
Connect to Microsoft Graph
Connect-MgGraph -Scopes "Group.Read.All","Directory.Read.All"
Syntax
Get-MgGroupMemberAsUser -GroupId <String>
Parameter Explanation
| Parameter | Description |
|---|---|
| -GroupId | The Object ID of the group |
The GroupId must be the GUID, not the display name.
Get-MgGroupMemberAsUser
When run without parameters, the cmdlet prompts you to enter the GroupId.
After providing it, the cmdlet returns only the user objects that are direct members of the group.
Get-MgGroupMemberAsUser -GroupID efba43ca-ff99-4f70-b2c5-a97e9dbb75d2
This command retrieves all direct user members of the specified group, excluding:
Useful For
Get-MgGroupMemberAsUser -GroupID efba43ca-ff99-4f70-b2c5-a97e9dbb75d2 | Export-CSV D:/AbnormalSecurityGroup.csv -NoTypeInformation
This exports the list of user members to a CSV file.
Why Export?
Example with pagination:
Get-MgGroupMemberAsUser -GroupId efba43ca-ff99-4f70-b2c5-a97e9dbb75d2 -All
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.
© Created and Maintained by LEARNIT WELL SOLUTIONS. All Rights Reserved.