question

RogerRoger-2394 avatar image
0 Votes"
RogerRoger-2394 asked KaelYao-MSFT edited

DLs and Nested DLs

Hi All

i have a DL in exchange online lets say dl1@contoso.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@contoso.com to a csv file. experts guide me. can office365 unified group be a member of a DL.

office-exchange-server-administrationoffice-exchange-online-itprooffice-exchange-server-mailflow
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KaelYao-MSFT avatar image
0 Votes"
KaelYao-MSFT answered KaelYao-MSFT edited

Hi @RogerRoger-2394

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.


53.png (42.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RogerRoger-2394

Just checking in to see if above information was helpful.
Please let us know if you would like further assistance.

0 Votes 0 ·