How to export Distribution List & its nested Distribution Lists' members to CSV file

raj a 316 Reputation points
2024-10-17T15:31:33.21+00:00

Hello,

We want to export all members of one large distribution list and its nested distribution lists. How can we do that?

Regards,

Raj

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,542 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,641 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
2,113 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,552 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 106.6K Reputation points MVP
    2024-10-17T16:10:02.8033333+00:00

    Use PowerShell, or if you don't know how to write such a script, look up examples online - there are plenty such scripts. Here is one of mine: https://www.michev.info/blog/post/4394/report-on-recursive-group-membership-via-exchange-powershell

    1 person found this answer helpful.
    0 comments No comments

  2. Xintao Qiao-MSFT 3,450 Reputation points Microsoft Vendor
    2024-10-18T02:32:16.9466667+00:00

    Hi, @raj a

    As Vasil Michev said, using Power Shell is the fastest way to operate with large distribution lists.

    Unfortunately, the current Exchange tag is not focused on providing scripting. I'm going to add Power Shell tag for you.

    From my personal point of view, I tried to write the following script for your reference.

    User's image

    function Get-DistributionGroupMembers {
        param (
            [string]$GroupName
        )
        $Group = Get-DistributionGroup -Identity $GroupName
        $Members = Get-DistributionGroupMember -Identity $GroupName
        foreach ($Member in $Members) {
            if ($Member.RecipientType -eq 'MailUniversalDistributionGroup' -or $Member.RecipientType -eq 'MailUniversalSecurityGroup') {
                Get-DistributionGroupMembers -GroupName $Member.Name
            } else {
                $Member | Select-Object Name, PrimarySmtpAddress
            }
        }
    }
    $GroupName = "test1016@****.com"
    $Results = Get-DistributionGroupMembers -GroupName $GroupName
    $Results | Export-Csv -Path "C:\users\DistributionListMembers.csv" -NoTypeInformation
    

    User's image

    User's image

    User's image

    There is a similar case here for your reference. exchange online : Export list of nested distribution group members in entire forest via powershell in csv format - Microsoft Q&A


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.