Forum Discussion
Bulk add user 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.
I have also added the 'WhatIf' option by default.
#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.
http://thatlazyadmin.com
4 Replies
- Deleted
Shaun Hardneck what would be the header in CSV file? Just Name?
- Bric_100Copper Contributor
Deleted Just add the emailaddress in text file and feed to below script, it has status bar, error reporting & some handy features
https://gallery.technet.microsoft.com/Add-Bulk-Users-to-6f3014b2
- PaulJamesonCopper Contributor
Bric_100 That script got removed. Any chance to load here?
- Maris_MCopper Contributor
This script works for me:
$Dgroup = Read-Host 'Insert Distribution Group Name'
Import-Csv "C:\scripts\AddDistGroupMembers.csv" |
foreach{Add-DistributionGroupMember -Identity $DGroup -Member $_.email}And the .csv file has a header "email"