Many a times we are faced with the task of getting all the members in a distribution group, especially in a large group. It is very easy with Powershell. Run the following command,
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
this works very fine thanks
Glad it helped Luis.
Thanks
You cannot pipe from a format-table into an Export-Csv.
You have to use Get-DistributionGroupMember –identity “group name” | Select-Object name, primarysmtpaddress | Export-CSV c:members.csv
See http://blogs.msdn.com/b/powershell/archive/2007/03/07/why-can-t-i-pipe-format-table-to-export-csv-and-get-something-useful.aspx
can i get output as count of members for each distribution group of my exchange 2007 from one command
Thanks for the explained post Anonymous.
For the problem Selvian posted, in detail (i.e.) I downloaded ActiveRoles Management Shell for Active Directory 32-bit in my windows xp from http://www.quest.com/powershell/activeroles-server.aspx
and then from Desktop ProgramsQuestSoftwareActiveR… lauch the shell. Otherwise you can use it from PowerGUI (getting it from FilesPowershell libraries)
Leo
Easiest will be to install PowerGUI, a free GUI to manage AD, Exchange, VMWare etc and run Get-QADGroupMember "group name" -Indirect from the script editor or load the quest snapin in powershell and run it from there.
http://www.powergui.org
Hey !
I have a distribution list which contains other distribution groups. Is there any way to list all the members who is member of the main group?
example:
Got a group called A, and this group is has members B and C. B and C contains users.
I need to get a list of alle the members who indirectly is member of the main group A.
Thanks.
Thanks Liam.
Very helpful ,Thanks Liam