Sunday 28 May 2017

Adding all Distribution List to a single Distribution List O365 PowerShell

Or, Making all DLs the member of a Global DL in O365
Or, How to add all DLs to a single global DL
Or, Creating a global DL containing all other DLs as member

Descriptions: In this article we are going to learn “How to add all other DLs in a Global DL member list”. Guys, this is something very common requirement across all type of organizations where people want to have a DL containing all other small DLs as a member, so that a Single mail can be sent to everyone by sending that to one DL instead of sending that to multiple DLs.

Yes, there is another way to achieve this requirement and that it creating a Dynamic DL which may by default contain all active mailboxes/users as a member. But, we will discuss about this latter in a separate detailed article.

Connect to office365 server PowerShell admin console with administrative privilege.

Run below command to export all the DLs in to a CSV file
Get-DistributionGroup -ResultSize unlimited | select displayname,PrimarySmtpAddress | Export-CSV d:\temp\DLs.csv

Run below command to import and add all the DLs to specified global DL
Import-Csv D:\temp\DLs.csv | foreach {Add-DistributionGroupMember -Identity -Member $_.displayname}

IMP Notes:
1. You can change the path as per your environment for exporting and importing the CSV file.
2. Do not modify anything in the exported CSV file.
3. DLs whichever are exported in the CSV file, would be added to the specified global DL. In my case it is

Cheers, please write me back if you have any query or feedback.

No comments:

Post a Comment