Skip to content

Add User to Multiple M365 Distribution Lists

Updated: at 07:54 PM

This can be one of those scripts you need occasionally, but a complete time saver. If HR has requested an update to distribution lists (Ha! what world do we live in?) or someone has slipped through the dynamic groups and it requires manual action, look no further!

First, we create a .CSV file which will contain the Groups. Inside the CSV, Column B will need to contain the header “Group Name”. You can also use the primary email address of the Distribution Group. In my case, I exported the Distribution Lists from the Microsoft Admin portal and used the export as my imported CSV in the script.

An example of my CSV is as follows:

GroupIDGroup NameGroup AliasGroup primary email
ab12cd34All CompanyAll Company[email protected]

This is wrapped into a variable named $groups. My export was saved locally onto the C:\ Drive in the example location.

$groups = Import-Csv "C:\Users\Example\Documents\DistributionLists\HR-export.csv"

We define the column in the CSV we are going to select with the following:


Select -ExpandProperty "Group Name"

We create a ForEach Loop and the script will then add the user into each Distribution List defined in the CSV. I’ve added a line “write-host” for visual reference and to catch any groups that might fail.

Powershell Script

$groups = Import-Csv "C:\Users\Example\Documents\DistributionLists\HR-export.csv" | Select -ExpandProperty "Group Name"
ForEach($group in $Groups ){
    Add-DistributionGroupmember -Identity $group -member "[email protected]"
    write-Host "Adding user to $group" -ForegroundColor Red
    }

✨ Feedback & Suggestions

If you have any suggestions/feedback, you can contact me via my email.