About Me

My photo
"Smoke me a kipper, I'll be back for Breakfast" - one man's journey through life with IT and all things related to it whether it's purely technical or just for fun...

Note - Any posts on this blog are purely my own personal opinion and do not reflect any opinions of companies and/or people that I mention. All advice is given to help you but I cannot be held responsible for your actions should you decide you want to try these things out yourself!

Monday 30 January 2012

Exchange 2007/2010 - Powershell to obtain Distribution Group Members

The PowerShell is probably one of the best innovations within Exchange in the last two releases.  The only problem is that it does take a lot of getting used to and also you do need to have a little programming knowledge to work out the syntax (language for those not in the know) to make it do what you want.  Like all things Microsoft, it never works how you want it to but for once I managed to get it to do what I want...



One handy script I have written will pull out Distribution Group Members into a CSV file.  It was actually quite straightforward and very handy if you are doing imports into 3rd party systems like a CRM or ERP solution.

Below is the script I used:

Get-DistributionGroup -Identity "Accounts" | Get-DistributionGroupMember | select-object Name, Alias, RecipientType, PrimarySMTPAddress | Export-CSV C:\Export.csv

Now this script specifically looks for the fields Name, Alias, Recipient Type and the Primary SMTP Address of each member.  You can get it look for other things as well such as City, Department etc but these fields will need to be populate otherwise you'll just get a blank!

Hope that helps you get something useful from the PowerShell...

No comments:

Post a Comment