| | | | | | | | |

Bulk add users to Distribution Group

Bulk add users to Distribution Group

I was ask recently to simplify a task for support staff to bulk add users to a distribution group. So i created the following script to add user from csv.

The script will ‘prompt’ for ‘Distribution Group’ name and will add users accordingly.

The script has the ‘WhatIf’ added by default you can remove it to apply the changes.

#Created to simplify daily tasks
#Web: http://thatlazyadmin.com
#Twitter: Shaun.Hardneck
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;
$DGroup = Read-Host 'Insert Distribution Group Name'
Import-Csv 'C:\Softlib\Users.csv' |
ForEach{
try { 
Add-DistributionGroupMember -Identity $DGroup -Member $_.name -ErrorAction stop -WhatIf
} 
catch [system.exception]
{
Write-Host "$_.name" -ForegroundColor Red 
}
Finally
{
}}

Hope this helps someone out there in the wild wild net.

#ThatLazyAdmin

Similar Posts

One Comment

Leave a Reply

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