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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#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.
Awesome! Its really awesome piece of writing, I have got much clear idea regarding from this article.