Back to script samples page
Exporting a list of all distribution groups into a CSV file

You can use distribution groups to create e-mail distribution lists.

Distribution groups can be used only with e-mail applications such as Microsoft Outlook to send e-mail messages to collections of users.

This script will export the list of distribution groups in your Office 365 organization into a CSV file.

#Connecting to Exchange Online

#Capture administrative credential for future connections.
$credential = get-credential

#Creates an Exchange Online session
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $credential -Authentication Basic -AllowRedirection

#Import session commands
Import-PSSession $ExchangeSession 

#Export list of all distribution groups to CSV file at c:\reports\distribution_group.csv
Get-DistributionGroup | Export-Csv C:\reports\distribution_group.csv
Downloaded 743 times
- - - - - (0)
Comments

No Comments