Exchange: How to list memberOf groups of a user?


Since this blog exists to explain how to list “memberof” groups of a DL, I am blogging again for user. There is no easy command to list all groups the user is member of. There is a little workaround to get the information from PowerShell.

User Member of which groups

On-Premises

Using AD cmdlets because they are very easy use. This command will display the parent (memberof) groups of their Email.

Replace <UserName> with the actual user’s name/alias in Get-ADUser command.

Get-ADUser <UserName> -Properties memberOf | Select-Object memberOf | Where-Object { $dn =[string] $_.memberOf ; Get-ADObject $dn -Properties mail | Select-Object mail}

Office 365/Exchange Online

End up using Exchange Online cmdlets in Exchange online. It may be little slower than On-Prem command. The idea is to run Get-User command with a filter if the user shows up in any group’s members. This will list the memberOf groups (of them email address).

Replace <user email address> with actual user’s email address in Get-User command.

$userDN = (Get-User <user email address>).distinguishedName ; $filter = "Members -eq '$userDN'" ; (Get-Group -Filter $filter | Select DisplayName, WindowsEmailAddress)

I wish Get-Mailbox or Get-User command have “memberof” property like in AD. But Exchange doesn’t. I hope this helped you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s