Exporting email distribution groups to CSV file

Salonge
Salonge used Ask the Experts™
I need several email lists by distribution group.  I am trying to export the groups out of Exchange 2010 into a csv file to be used in another application.  Can someone help with this?  I understand there is something that can be done in Powershell.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
Awarded 2018
Distinguished Expert 2018
Yep, on Exchange Powershell run:

Get-DistributionGroup | Export-csv -Notypeinformation "$env:userprofile\desktop\DistributionGroups.csv"

Open in new window


That should work into a CSV file on the desktop of the currently logged user.

Author

Commented:
When I run this script my file is blank.  Shouldn't I have to put the name of the group somewhere in this script?
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
Awarded 2018
Distinguished Expert 2018
let me double checked it
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
Awarded 2018
Distinguished Expert 2018
Get-DistributionGroup | ConvertTo-Csv -NoTypeInformation | Out-File "$env:userprofile\desktop\Di
stributiongroups.csv"

Open in new window

Author

Commented:
I am getting the error Get-DistributionGroup is not a recognized name of a cmdlet, function, script file or operable program.

Author

Commented:
This works to pull out the list of Distribution groups.  I was able to get a CSV of all of my Distribution groups.  Thank you.  But I need that list that I see when I do the Get-DistributionGroupMembers.  I want to be able to convert to a CSV by group.
Jose Gabriel Ortega CastroCEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
Awarded 2018
Distinguished Expert 2018
alright I'd fix the ps code into that
CEO Faru Bonon IT /Top Rated Freelancer on Upwork / Photographer
Awarded 2018
Distinguished Expert 2018
Get-DistributionGroup | %{
        Get-DistributionGroupMember $_ | select alias, UserPrincipalName,DisplayName,@{Name="GroupMembership";Expression={$groupname}}
    } |ConvertTo-Csv -NoTypeInformation | Out-File $env:USERPROFILE\desktop\member.csv

Open in new window

Author

Commented:
Thank you.  I had to do some other steps to connect to Office365, but this ultimately worked just fine.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial