Save time when creating and adding members to Office 365 distribution groups by CSV with scripts.

When you’re creating and adding members to Office 365 distribution groups by CSV in Office 365, it can be very time consuming to go one by one. Using the scripts below can help you save time and frustration when creating and adding members to distribution groups by CSV.

Scenario:

An organization is migrating from another email environment and would like to create their distribution groups on Office 365.

Solution:

1. Create Distribution Groups

Script:
Import-CSV “C:\CSG\distributiongroup.csv” | foreach {New-DistributionGroup -Name $_.name -Type $_.Type}

Example Of CSV:
Create a CSV, below is the name if the DG you are creating and set the type to distribution.

Office 365 Distribution Groups

 

2. Add Members to Distribution Group

Script:
Import-Csv “C:\CSG\addmem1.csv” | foreach{Add-DistributionGroupMember -Identity $_.identity -Member $_.members}

Example Of CSV:
Make sure that the members have the identity next to it “NAME OF THE DISTRIBUTION GROUP THEY ARE GOING TO BE A MEMBER OF”

Office 365 Distribution Groups

 

Use these scripts to save time and frustration when creating and adding members to Office 365 distribution groups by CSV.  For more MessageOps Tech Tips to improve your Office 365 experience, click here.

Was this article helpful?
YesNo