Report on your Office 365 Distribution Groups
To begin, you will need to connect to Microsoft Exchange Online.
$credential = Get-Credential
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $credential -Authentication Basic -AllowRedirection
This command is used to get the list of existing distribution groups.
To export the results into a CSV file, you can run the following command. You can replace the C:\reports\distribution_group.csv with a location and file name of your choosing.
Get-DistributionGroup | Export-Csv C:\reports\distribution_group.csv