Adding the Same Mailbox to Multiple Distribution Lists

A recent request asked how to add a single user (mailbox) to multiple distribution lists. The easy answer is to say that although it might be tedious, the simplest approach is to use the Exchange Admin Center or Microsoft 365 Admin Center to update the membership of the target groups.

This is an acceptable response when you have a small number of lists to update. It’s a little different when you need to add a mailbox to hundreds of lists, which was apparently the situation behind the plea. PowerShell is the obvious way to approach the problem.

Use an Array as Input

The first run at the code uses an array to hold the target distribution lists. After reading in the name of the mailbox to add and checking that it is a real mailbox, we call the Add-DistributionGroupMember cmdlet to update each target list.

Use a CSV File as Input

Populating an array can be error-prone. Here’s some updated code that reads the distribution lists in from a CSV file. The file is very simple (Figure 1) and contains the alias of each list under a heading called “Dl Alias.” If you don’t want to use the alias, you could use any of the value identifiers for a list like a display name, distinguished name, or primary SMTP address.

Input CSV for distribution lists
Figure 1: Input CSV for distribution lists

With the CSV file prepared, we can read it in with the Import-CSV cmdlet and use the alias in each line to identify the target distribution list. Here’s the code:

I’ve already answered the questioner in the Facebook group where the issue arose and document it here for anyone else who might be interested.

If our questioner only had a copy of the Office 365 for IT Pros eBook they would have found the answer themselves. The book contains hundreds of PowerShell examples. Subscribe and support the only book that constantly evolves to keep pace with Office 365.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.