question

Pamu avatar image
0 Votes"
Pamu asked KaelYao-MSFT commented

How to list all the distribution lists, M365 groups a user is a member of?

Hi everyone,

Is there a specific PowerShell script or any other method that I can use to list down all the Distribution List, Microsft365 Groups a specific member is a part of?

A script to list down all the Shared-Mailboxes a user has permission to would be appreciated too.
Like something that would help in an user off-boarding process?


Thanks in advance for the help!!!

windows-server-powershelloffice-exchange-server-administrationoffice-exchange-online-itproazure-ad-microsoft-account
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Pamu

I am writing here to confirm with you how thing going now?
If you have any questions or needed further help on this issue, please feel free to post back.

0 Votes 0 ·
michev avatar image
1 Vote"
michev answered michev commented

There are plenty examples available online, here's one of mine: https://www.michev.info/Blog/Post/2250/generating-a-report-of-users-group-membership-memberof-inventory
If you want a quick one-liner instead, 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 provide the DistinguishedName of the user.




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @michev ..really appreciate your help.

does this mean, we have to change the 'CN=user' -- the "user' portion of the script into the username of the user we are targeting?
what about the other parameters ?

Sorry for this, I am still new to these technologies.

0 Votes 0 ·

Generally speaking, yes, but it is better to actually fetch the value first:

 Get-Mailbox user | select DistinguishedName
    
 DistinguishedName
 -----------------
 CN=user,OU=tenant.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=EURPR03A001,DC=prod,DC=outlook,DC=com

Once you have the value, copy it and replace in the above example. Don't forget to enclose it in single quotes, and keep the rest of the filter. Or you can just try the script I linked to, it will do it on your behalf.

0 Votes 0 ·
amanpreetsingh-msft avatar image
1 Vote"
amanpreetsingh-msft answered

Hi @PamudithaMadushanka-8226 ·

If you are using Azure AD user account, you can use below Graph Call:

Permissions required :
Delegated permissions - User.Read, GroupMember.Read.All, Directory.Read.All, Directory.ReadWrite.All, Directory.AccessAsUser.All


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.