How do I export distribution groups and Mail contact to a csv file in Exchange

Hi Guys,

I would like a exchange shell script to help me understand which contacts belong to which distribution list.

Thanks
chrislindsayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam FarageEnterprise ArchCommented:
Get-DistributionGroupMember -Identity <dl_name@company.com> | Select Identity, PrimarySmtpAddress | Export-CSV C:\DistributionGroup.csv
0
chrislindsayAuthor Commented:
sorry for my ignorance but what do i ender in the <dl_name@company.com> part of the script as all my contacts have different email domains?  Thanks
0
tshearonCommented:
You could do the following:

Get-DistributionGroup “your_distro_name” | Get-DistributionGroupMember | Select Name,RecipientType | export-csv c:\distro_contacts.csv

This will list the members of your desired distribution list and provide their recipient type. Simply filter out every RecipientType except MailContact.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

chrislindsayAuthor Commented:
Hi I would like all the distribution groups returning.....
0
Gareth GudgerCommented:
Check out this blog post here.
http://oxfordsbsguy.com/2014/04/21/exchange-powershell-how-to-enumerate-distribution-lists-managers-and-members/

foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | ft alias, @{label=’Group′;expression={$group.name}}} | export-csv c:\distro_contacts.csv
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chrislindsayAuthor Commented:
Worked well thanks
0
Gareth GudgerCommented:
Great stuff.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.