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

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Exchange Exchange Server Management
Exchange Hybrid management
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    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. Anonymous
    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".


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.