Exchange Server: Find user in all distribution groups

Sometimes we are asked to get a list of distribution groups that a user belongs to. We can do this with the help of Exchange PowerShell commands.

Get-DistributionGroup -ResultSize unlimited | Where {(Get-DistributionGroupMember $_ | ForEach {$_.PrimarySmtpAddress}) -contains “<user’s email address>”} | Select Name, PrimarySmtpAddress

If you want to save the results in CSV file, redirect the output to Out-File

Get-DistributionGroup -ResultSize unlimited | Where {(Get-DistributionGroupMember $_ | ForEach {$_.PrimarySmtpAddress}) -contains “<user’s email address>”} | Select Name, PrimarySmtpAddress | Out-File <path of the file\results.csv

Advertisements

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 )

Google+ photo

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

Connecting to %s