As a community person i run a lot of discussion lists (in Exchange called distribution list) and always adding new people to these lists.
In the Exchange Admin interface this takes to separate steps and filling out several fields of metadata . The two separate steps are:
1. Adding the contact
2. Adding that contact to the distribution group
These two steps can easily take 2-3 minutes and if you have 100 people to add……..
Turns out Exchange doesn’t need the contacts added, just an email address but the Exchange Admin UI does allow this…Luckily their PowerShell cmdlet does!
The script is really easy too!
$credential = get-credential #Creates an Exchange Online session $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $credential -Authentication Basic -AllowRedirection #Import session commands Import-PSSession $ExchangeSession Add-DistributionGroupMember -Identity "PUG" -Member firstname.lastname@example.org
Of course this could be written as a for-each loop reading a CSV file, but i found in many cases using Excel to create the Command works better for trouble shooting etc.
Since there are only two parameters the Excel function is very straight forward:
="Add-DistributionGroupMember -Identity "& B2 & " -Member " & A2
All i have to do is paste in the email address I want to add and autofill the rest!