Add User to Distribution Group

Applies to Exchange, and O365.
Modules needed: Exchange, or Microsoft.Exchange.Management.ExoPowershellModule

This is a simple script that just asks for input on adding members to a distribution group. The reason I made this script was because I wanted to simplify this process for non-admin IT folks, and enter multiple users at a time.

To add multiple users, separate them with commas.
Example: Members: druggeri,tdanza,pporter


$dl = Read-Host "Distribution Group"
Write-Host
get-distributiongroup -identity $dl
Write-Host
Write-Host
$members = Read-Host "Members"
$members = $members.split(',')
foreach ($m in $members) {
  Add-DistributionGroupMember -identity $dl -member $m }
Write-Host
Write-Host "Confirmation:" -ForegroundColor Green
get-distributiongroupmember -identity $dl | Format-Table -AutoSize

At the end of the script, a confirmation is shown using get-distributiongroupmember on the entered group. This is just so you can verify your change applied, and that the correct users were added.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s