Powershell tip to get desired distribution group name and members in csv format
I'm trying to get a list of every distribution group and the DG Name (column 1) SEPARATOR- List-Of-All-DG-Member-Email-Addresses-Separated-With-Space (column 2). I'm using "Get-DistributionGroupMember -identity "DistributionListName" | Export-Csv C:\MyFile.Csv", but I have hundreds of DL's and doing them one at a time is extremely tedious. I'm thinking a get-distributiongroup | get-distributiongroupmember | ft something | export-csv, but I'm not getting it right and could use assistance.
March 2nd, 2012 10:11pm

Take a look at this: http://www.energizedtech.com/2010/03/powershell-show-group-membersh.html This uses the W2K8 R2 Get-ADGroup functions to enumerate the groups and write each group membership to a separate CSV file. It does require that you define your own function, but it seems to do the trick. Jim McBee - Blog - http://mostlyexchange.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
March 3rd, 2012 2:33am

I once wrote a script to list all distribution groups and members of those groups. It uses the Add-Member method, which is slow compared to Select-Object. On the other hand, it allows for a structured approach which is easy to modify and extend. See if that helps. (Not Karl Mitschke's script, whom I btw hold in high esteem for his PowerShell skills.) Powershell command to list all distribution groups and members of those groups http://social.technet.microsoft.com/Forums/en-SG/exchangesvradmin/thread/63ad55d1-1393-4533-8065-1d7cbd8657faMCTS: Messaging | MCSE: S+M
March 3rd, 2012 2:52am

you can try running following vbs script http://messagingserversupport.com/2012/01/19/extracting-distribution-list-information-in-exchange/ Exchange Rocks
Free Windows Admin Tool Kit Click here and download it now
March 3rd, 2012 3:03am

Hi Kanien, From your description, I understand that you want use PowerShell to export Groups with Distribution Group Name, members, and members' email address, right? I write this script to do that, hope can give you some help: $Groups=Get-DistributionGroup $Groups| foreach{ $GroupName=$_.Name $Report+=Get-distributionGroupMember -identity $_.identity| select @{Name='Distribution Group'; Expression={[String]::join(";", $GroupName)}}, Name, PrimarySmtpAddress} $Report| export-csv "c:\MyFile.csv" -notype Thanks, Evan Liu TechNet Subscriber Supportin forum If you have any feedback on our support, please contact tngfb@microsoft.com Evan Liu TechNet Community Support
March 5th, 2012 12:22am

Hello Kanien, Any updates on this issue? Thanks, Evan Liu TechNet Subscriber Supportin forum If you have any feedback on our support, please contacttngfb@microsoft.com Evan Liu TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
March 5th, 2012 8:50pm

Hey Evan, I'm getting this error for every list but the first one: Method invocation failed because [System.Management.Automation.PSObject] doesn't contain a method named 'op_Addition'. At C:\Scripts\distribution_list.ps1:7 char:10 + $Report+= <<<< Get-distributionGroupMember -identity $_.identity| select @{Name='Distribution Group'; Expression={[St ring]::join(";", $GroupName)}}, Name, PrimarySmtpAddress} + CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
March 13th, 2012 11:57pm

Hello, I didn't see any error in my lab (Exchange 2007), please use this to have a try: $Reports=@() $Groups=Get-DistributionGroup $Groups| foreach{ $GroupName=$_.Name $Report=Get-distributionGroupMember -identity $_.identity| select @{Name='Distribution Group'; Expression={[String]::join(";", $GroupName)}}, Name, PrimarySmtpAddress $Reports=$Reports+$Report } $Reports| out-file "c:\MyFile2.txt" Then check whether you will get error or not. Thanks, Evan Liu TechNet Subscriber Supportin forum If you have any feedback on our support, please contacttngfb@microsoft.com Evan Liu TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 6:38am

Hello, Any updates? Thanks, Evan Liu TechNet Subscriber Supportin forum If you have any feedback on our support, please contacttngfb@microsoft.comEvan Liu TechNet Community Support
March 17th, 2012 11:52pm

That worked. Oh and, thank you :)
Free Windows Admin Tool Kit Click here and download it now
March 18th, 2012 6:05am

Even I'm getting Unexpected token 'Report' in expression or statement. At line:1 char:44 What do you thinks?
June 1st, 2012 8:59am

Could you show me the exact error? Thanks, Evan Evan Liu TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
June 1st, 2012 9:01pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics