$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"
}
}
}