Export All Distribution Lists and Members using PowerShell

Export All Distribution Lists and Members using PowerShell

To export all distribution groups and their members to a CSV file, use the following PowerShell script:


Please refer to:




#Read more: www.sharepointdiary.com/2022/03/office-365-export-distribution-list-members-to-csv-using-powershell.html#ixzz84o9taRMB


Copy to notepad and Rename file to  ExportDistributionList.ps1 and run in powershell.


$CSVFilePath = “C:\Temp\DL-Members.csv”

Try {

    #Connect to Exchange Online

    Connect-ExchangeOnline -ShowBanner:$False

    #Get all Distribution Lists


    $DistributionGroups = Get-DistributionGroup -ResultSize Unlimited

    $GroupsCount = $DistributionGroups.Count

    $Counter = 1

    $DistributionGroups | ForEach-Object {

        Write-Progress -Activity “Processing Distribution List: $($_.DisplayName)” -Status “$Counter out of $GroupsCount completed” -PercentComplete (($Counter/$GroupsCount)*100)

        $Group = $_

        Get-DistributionGroupMember -Identity $Group.Name -ResultSize Unlimited | ForEach-Object {

            $member = $_

            $Result += New-Object PSObject -property @{

            GroupName = $Group.Name

            GroupEmail = $Group.PrimarySmtpAddress

            Member = $Member.Name

            EmailAddress = $Member.PrimarySMTPAddress

            RecipientType= $Member.RecipientType





    #Get Distribution List Members and Exports to CSV

    $Result | Export-CSV $CSVFilePath -NoTypeInformation -Encoding UTF8


Catch {

    write-host -f Red “Error:” $_.Exception.Message




#Read more: www.sharepointdiary.com/2022/03/office-365-export-distribution-list-members-to-csv-using-powershell.html#ixzz84o9nxKvH


Kon Belieu


Comments are closed

Latest Comments

No comments to show.