Forum Discussion

ndubs's avatar
ndubs
Copper Contributor
May 13, 2021

M365/AzureAD Equivalent Powershell Command for Get-ADPrincipalGroupMembership

  My question is, does a cmdlet exist that does the equivalent function of Get-ADPrincipalGroupMembership for M365 or AzureAD, and if not is there a way to achieve a similar functionality without e...
  • VasilMichev's avatar
    May 13, 2021
    For Exchange Online, use this:

    Get-Recipient -Filter "Members -eq 'CN=user,OU=domain.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=EURPR03A001,DC=prod,DC=outlook,DC=com'"

    where you need to specify the DistinguishedName of the user. If you prefer using Azure AD cmdlets:

    Get-AzureADUser -ObjectId 58ab2b38-818c-4b85-8871-c9766cb4791b | Get-AzureADUserMembership

    Or better yet use Graph: https://www.michev.info/Blog/Post/2331/graph-api-adds-support-for-transitive-membership-queries

Resources