Add contacts from a CSV file to a distribution list

btny
btny used Ask the Experts™
on
Hi,

I have just imported several CSV files into mail enabled contacts in MS Exchange 2010 using this command

Import-Csv C:\Export\EarlyIntervention.csv | ForEach { New-MailContact -Name $_.DisplayName -ExternalEmailAddress $_.EmailAddress -OrganizationalUnit "BoardMembers" }

So now those users are contacts in my AD/MX servers.

I wish to be able to import those members into a distribution list called @BoardMembers howeveer when I run this command

Import-Csv C:\Export\BoardMembers.csv | ForEach-Object -Process { Add-DistributionGroupMember -@BoardMembers -Member $_ }

It doesnt work

Any advice on how to do this is appreciated!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try this

This assumes your csv file has a header with Displayname and it is the users Displayname, you could also use email.

Import-Csv C:\Export\BoardMembers.csv | ForEach{ Add-DistributionGroupMember -identity '@BoardMembers' -Member $_.DisplayName }
Kent DyerIT Security Analyst Senior

Commented:
Did you see this?

http://tech-informer.com/exchange-2007-powershell-commands-and-tips-115/

Import-Csv | ForEach { New-MailContact -Name $_.Name -Alias $_.Alias -ExternalEmailAddress $_.EmailAddress -OrganizationalUnit Users }

HTH,

Kent

Author

Commented:
Ken, YOU ARE MY HERO!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial