Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Add DL Members In Bulk

$
0
0

$FileLocation = read-host -prompt "Enter the full csv file path(Ex: C:\folder\File.csv)"

$smtp = read-host -prompt "Enter the name of the .CSV Column Header that holds the members to add"

$DLNAME = read-host -prompt "Enter name of DL to add members to"

Import-Csv "$FileLocation" | Foreach-object{

$Account = Get-User -Anr $_.$smtp

$Account | ForEach-Object{

if ($_.RecipientType -eq "UserMailbox")

{

Add-DistributionGroupMember -identity $DLNAME -member $_.DistinguishedName

}

elseif ($_.RecipientType -eq "User")

{

"Not a Mail User"

}

else

{

"Not a Domain User"

}

}

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles