May 01 2017 10:38 PM
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.
Nov 26 2017 10:00 PM
@Shaun Hardneck what would be the header in CSV file? Just Name?
Jan 15 2019 06:43 AM
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"
Mar 19 2019 10:10 AM
@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
Mar 14 2021 06:02 PM
@Bric_100 That script got removed. Any chance to load here?