DLs and Nested DLs

Roger Roger 5,446 Reputation points
2022-04-19T01:42:29.37+00:00

Hi All

i have a DL in exchange online lets say dl1@Company portal .com and the members of this DL are users as well as another DLs. in this way i have many nested DLs.
how can i pull the users and all nested DLs which are in dl1@Company portal .com to a csv file. experts guide me. can office365 unified group be a member of a DL.

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,383 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,498 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,676 Reputation points Microsoft Vendor
    2022-04-20T01:39:46.613+00:00

    Hi @Roger Roger

    Did you mean Microsoft 365 group when you say office365 unified group?
    If yes, Microsoft 365 Groups don't support nesting with other Microsoft 365 Groups or with distribution or security groups.
    194455-53.png


    To get the members in DL and nested DLs, would the following script work for you:

    # Exporting DL Objects  
    Get-DistributionGroupMember -Identity  DL1 | where {$_.RecipientType -eq 'UserMailbox'} |Select-Object name, WindowsLiveID |  Export-Csv "C:\scripts\mailbox_in_DG.csv"  
    
    #Export Only DL Names from the Parent Group  
    Get-DistributionGroupMember -Identity  DL1 | where {$_.RecipientType -ne 'UserMailbox'} | Select-Object name | Export-Csv  "C:\scripts\nestedDG.csv"  
      
    # Exporting Nested DL Objects With individual File   
      
    Import-Csv  "C:\scripts\nestedDG.csv" |  
      
    foreach{  
      
    Get-DistributionGroupMember -Identity   $_.Name  | Select-Object name, WindowsLiveID | Export-Csv -Path  C:\scripts\"$($_.Name)".csv -NoTypeInformation  
      
    }  
    

    In mailbox_in_DG.csv you would see normal user mailboxes in this DL.
    In nestedDG.csv you would see names of nested DLs in this DL.
    It would also output the membership of the nested DLs in the csv files which are named in the format <nested DL name>.csv.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful