Add members to distribution group using PowerShell

For Office 365 first Connect PowerShell to Exchange Online

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

For both Office 365 and on-premise Exchange server:

Prepare the CSV file for the import, a list with a title (lets say “alias”) and all the email addresses of the users that will be added to the list.

Run the import command:

Import-CSV list.csv | foreach {Add-DistributionGroupMember "group email address" -Member $_.alias)

 

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

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