logo
search
Others

How to Get All Microsoft 365 Group Memberships with PowerShell

Emma BrownEmma Brown Oct 15, 2026 869 views

Question details

The user needs to find PowerShell alternatives to the Get-ADPrincipalGroupMembership cmdlet for retrieving a user's memberships in Microsoft 365, security, and distribution groups.

How to Get All Microsoft 365 Group Memberships with PowerShell
Product
Microsoft 365
Device & OS
not provided
Scenario
Retrieving comprehensive cloud group memberships for a specific user in a Microsoft 365 environment.
Observed behavior
On-premises Active Directory cmdlets are insufficient for cloud-native directories, requiring Microsoft Graph or Exchange Online PowerShell commands to access the data.
Before you start

Ensure you have installed the Microsoft Graph PowerShell module and possess administrative privileges (such as Global Reader or Groups Administrator) to query directory data.

Solution 1Recommended

Use Microsoft Graph PowerShell

Microsoft Graph is the recommended, modern approach for retrieving comprehensive membership data for Microsoft 365 and security groups.

Microsoft Graph PowerShell replaces legacy Azure AD cmdlets, offering unified and secure access to your Microsoft 365 tenant's directory data.

1
Install the Microsoft Graph module

Open PowerShell as an Administrator and execute 'Install-Module Microsoft.Graph' to download the required components.

2
Authenticate with Microsoft 365

Run 'Connect-MgGraph -Scopes "GroupMember.Read.All", "User.Read.All"' and sign in using your administrator credentials.

3
Retrieve the user's group memberships

Use the 'Get-MgUserMemberOf' cmdlet, specifying the user's Object ID or User Principal Name (UPN), to list all of their associated cloud groups.

Use Microsoft Graph PowerShell
Best Practice: Always use Microsoft Graph for cloud-native queries rather than enumerating every group and comparing members, as it is significantly more efficient.
Free Microsoft Office alternative

Need a Lightweight Office Alternative?

While managing Microsoft 365 environments requires complex PowerShell scripts, your daily document tasks shouldn't have to rely on expensive and heavy software. WPS Office provides a free, lightweight, and fully compatible alternative to Microsoft Office, making it incredibly easy to create and edit documents offline or online.

Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx)Lightweight architecture for fast startup and minimal system resource consumptionFamiliar tabbed user interface for seamless and instant migrationFree to download and use for all fundamental everyday office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Can I use Get-ADPrincipalGroupMembership for Microsoft 365 cloud groups?

No, the Get-ADPrincipalGroupMembership cmdlet is specifically designed for on-premises Active Directory environments. For Microsoft 365 cloud groups, you must use Microsoft Graph or Entra PowerShell.

Is the legacy Azure AD PowerShell module still recommended?

Microsoft is actively deprecating the legacy Azure AD modules (MSOnline and AzureAD). IT administrators are strongly advised to migrate all scripts to Microsoft Graph PowerShell for long-term compatibility and support.

What permissions are required to query Microsoft 365 group memberships via PowerShell?

The account executing the commands must have appropriate directory read permissions. Common roles that provide this access include Directory Readers, Groups Administrator, or Global Administrator.