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.
$CheckName = Read-Host "Enter Name of mailbox to add" Try { $Mbx = Get-Mailbox -Identity $CheckName -ErrorAction Stop | Select -ExpandProperty PrimarySmtpAddress} Catch { Write-Host "No mailbox can be found called" $CheckName; break } $DLs = @("Company Sales", "Trading Partners Team","Planner Gurus") ForEach ($DL in $DLs) { Add-DistributionGroupMember -Identity $DL -Member $Mbx }
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.

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:
$CheckName = Read-Host "Enter Name of mailbox to add" Try { $Mbx = Get-Mailbox -Identity $CheckName -ErrorAction Stop | Select -ExpandProperty PrimarySmtpAddress} Catch { Write-Host "No mailbox can be found called" $CheckName; break } $DLs = Import-CSV "C:\Temp\InputDLs.csv" ForEach ($DL in $DLs) { Try { Add-DistributionGroupMember -Identity $DL."DL Alias" -Member $Mbx -ErrorAction Continue } Catch { Write-Host "Couldn't add" $Mbx "to DL" (Get-DistributionGroup -Identity $DL."DL Alias").DisplayName } }
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.