Share via


Ο365 : Add Members In Distribution List Using PowerShell and CSV list File

The steps below show how we can add members in distribution list by using a PowerShell script and a CSV file.

Step 1. Create the CSV File

 On the first step we need to create a csv file with the column "Name

Name

user1@contoso.com

user2@contoso.com

user3@contoso.com

user4@contoso.com

user5@contoso.com

user6@contoso.com

user7@contoso.com

user8@contoso.com

 

 

Step 2. Run the PowerShell script

The second step is to run the below PowerShell script.

 Note: Change the file path first and the alias of distribution list 

Import-Module ExchangeOnlineManagement
 
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $truE
 
Import-CSV C:\csv\newmembers.csv | ForEach {Add-DistributionGroupMember -Identity ALIASOFDISTRIBUTIONLIST Member $_.Name}
 
Write-Host  "DONE RUNNING SCRIPT, check for errors"
 
Read-Host -Prompt "Press Enter to exit"