We help IT Professionals succeed at work.

How to export all members of a distribution list  from office 365

Jason Day
Jason Day asked
on
We have switched over to office 365 and I need to export a list of all members in a certain DL to a csv file that includes their name and email address.
Thank you.
Comment
Watch Question

BRONZE EXPERT

Commented:
Connect to O365 tenant using powershell and run

Get-DistributionGroupMember -Identity "Group Name" | Select Name, PrimarySmtpAddress | Export-csv members.csv -NoTypeInformation
Mohammed KhawajaManager - Infrastructure:  Information Technology
BRONZE EXPERT

Commented:
Jason DayIT Director

Author

Commented:
I tried the second option but all it gives me is the list of distribution lists, not the members in a particular list. How do I use my local powershell in 365?
BRONZE EXPERT

Commented:
https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx
This will help in connecting powershell to O365
Jason DayIT Director

Author

Commented:
I am using powershell but it won't take commands like Get-Mailbox
Jason DayIT Director

Author

Commented:
The term 'Get-DistributionGroup' is not recognized as the name of a cmdlet, function, script file, or operable program.
 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:47
+ $objDistributionGroups = Get-DistributionGroup <<<<  -ResultSize Unlimited
    + CategoryInfo          : ObjectNotFound: (Get-DistributionGroup:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
BRONZE EXPERT
Commented:
Have you installed all prerequisite for connecting to O365
Microsoft Online Services Sign-In Assistant
Windows Azure Active Directory Module for Windows PowerShell

Follow these articles and you should be able to connect to O365 without issues

https://supertekboy.com/2014/02/20/office-365-how-to-connect-with-powershell/
https://supertekboy.com/2015/04/30/easily-connect-powershell-to-exchange-online/
Jason DayIT Director

Author

Commented:
Thank you so much for the help.