Forum Discussion
ndubs
May 13, 2021Copper Contributor
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...
- May 13, 2021For 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
VasilMichev
May 13, 2021MVP
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
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
- ndubsMay 14, 2021Copper Contributor
VasilMichevPerfect, thank you so much. Not sure how I missed the Get-AzureADUserMembership cmdlet, but it was exactly what I was looking for.