question

RogerRoger-2394 avatar image
0 Votes"
RogerRoger-2394 asked itchsun-msft edited

Export DL members

Hi All

I have a distribution list lets say dl1@contoso.com and it has many nested DL's and also many office365 unified groups. I want to export all the members of this DL dl@contoso.com which includeds nested DLs members and office365 groups members. is there any script to do this, please guide me.

office-sharepoint-onlineoffice-exchange-server-administrationoffice-exchange-online-itprooffice-exchange-server-itpro
· 2
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.

@RogerRoger-2394 ,

Would you tell me whether your issue has been resolved or have any update ?
I am looking forward to your reply.

Thanks,
Echo Du

0 Votes 0 ·

Hi @RogerRoger-2394
According to your description, this question seems to be related to Sharepoint, so we would move the irrelevant tags.

0 Votes 0 ·
EchoDu-MSFT avatar image
0 Votes"
EchoDu-MSFT answered NishantJainCSE2019-4460 commented

@RogerRoger-2394 ,

You could execute the following script:

The first script: List the specific Distribution Group Members.

 #Connect to Exchange Online Remote PowerShell.
 Import-Module ExchangeOnlineManagement
 Connect-ExchangeOnline -UserPrincipalName "user@test.com" -ShowProgress $true
 #List all the Microsoft 365 groups in Microsoft 365.
 Get-UnifiedGroup -ResultSize Unlimited
 #list all members of a selected single Microsoft 365 group 
 Get-UnifiedGroupLinks –Identity test –LinkType Members –ResultSize Unlimited

The second script: Get all the information related to every Microsoft 365 Group member, and export to CSV file.

 #Connect to Exchange Online Remote PowerShell.
 Import-Module ExchangeOnlineManagement
 Connect-ExchangeOnline -UserPrincipalName "user@test.com" -ShowProgress $true
    
 #--------------------------#
 $Groups = Get-UnifiedGroup -ResultSize Unlimited
 $Groups | ForEach-Object {
 $group = $_
 Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members -ResultSize Unlimited | ForEach-Object {
 New-Object -TypeName PSObject -Property @{
 Group = $group.DisplayName
 Member = $_.Name
 EmailAddress = $_.PrimarySMTPAddress
 RecipientType= $_.RecipientType
 }}}} | Export-CSV "C:\\Office365GroupMembers.csv" 

Thanks,
Echo Du
================
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.





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.

udara avatar image
0 Votes"
udara answered

You can use following script.

https://gallery.technet.microsoft.com/Export-Nested-DL-Members-e9ef3427

(Don't forget to Accept as answer if this is helpful)





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.