Exchange 2007 - How to get a list of distribution groups certain user is member of...
Hi!
Sometimes we have a problem to find out in which distribution groups certain user is present - is there a PowerShell command that could do this?
Thanks!
June 16th, 2010 11:56am
Hi BPlay !
I M putting 2 links here I hope you will get the answer of your question.
http://ss64.com/ps/
http://www.microsoft.com/downloads/details.aspx?FamilyId=3B3F7CE4-43EA-4A21-90CC-966A7FC6C6E8&displaylang=en
Regards.
Shafaquat Ali.M.C.I.T.P Exchange 2007 M.C.I.T.P Windows Server 2008 M.C.T.S OCS Server 2007 R2
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2010 12:14pm
Hi!
Sometimes we have a problem to find out in which distribution groups certain user is present - is there a PowerShell command that could do this?
Thanks!
Hi,
Yes there is. You can use either of these 2 commands:
1. Get-DistributionGroup | where { (Get-DistributionGroupMember $_ | foreach {$_.PrimarySmtpAddress}) -contains "yourUserPrimaryEmailAddress" }
2. Get-DistributionGroup | where { (Get-DistributionGroupMember $_ | foreach {$_.name}) -contains "yourUserName" }
Regards,
Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM)
www.HostingController.com
June 16th, 2010 12:23pm
Or you can use a small script, such as this:
$User = read-host -Prompt "Enter Username"
"User " + $User + " is a member of the following groups:"
ForEach ($Group in Get-DistributionGroup)
{
ForEach ($Member in Get-DistributionGroupMember -identity $Group | Where { $_.Name –eq $User })
{
$Group.name
}
}Martin Sundstrm | Microsoft Certified Trainer | MCITP: Enterprise Messaging Administrator |
http://msundis.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2010 1:11pm
Thank you for all sharing!
Additional helpful commands:
Get-DistributionGroupMember –identity “group name”
In order to select the properties we need, pipe the command to format-table with the necessary values.
Get-DistributionGroupMember –identity “group name” | ft name, primarysmtpaddress
As usual, we can export the output to a txt or csv file.
Get-DistributionGroupMember –identity “group name” | ft name, primarysmtpaddress | Export-CSV c:\members.csv
ThanksYour expertise never fails to impress!
June 17th, 2010 6:42am
Then it lists them non-alphabetically. Here's how to list group members onscreen in alphabetical order without piping them to a file, opening in Excel and sorting.
Get-DistributionGroupMember -Identity "group name" |
Sort -Property DisplayName
(When are they going to let us Exchange Admins see and sort our mailboxes by size in the GUI? Yes, I will beat the dead horse until it gets up and drinks the water.)
Free Windows Admin Tool Kit Click here and download it now
December 2nd, 2010 4:22pm