How to Get All Microsoft 365 Group Memberships with PowerShell
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.

- 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.
Ensure you have installed the Microsoft Graph PowerShell module and possess administrative privileges (such as Global Reader or Groups Administrator) to query directory data.
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.
Open PowerShell as an Administrator and execute 'Install-Module Microsoft.Graph' to download the required components.
Run 'Connect-MgGraph -Scopes "GroupMember.Read.All", "User.Read.All"' and sign in using your administrator credentials.
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 Exchange Online PowerShell for Distribution Groups
If you specifically need to find memberships within distribution lists or mail-enabled security groups, Exchange Online PowerShell provides targeted cmdlets.
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.

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.




