Importing csv list of contacts into Exchange 2007 GAL and create Distribution Group

exchange-2007

Here's the situation:

We have a list of about 1,000 contacts (Lawyers in the area our court serves) with name and email address. I've been asked to create an email distribution list that can be used to sent emails to all of the external users on that list. I've seen various articles using the Exchange Management Shell and the Import-csv command piped through a ForEach-Object to a New-MailContact to set up the contacts.

However, Exchange Management Shell is rather unhelpful, and it isn't working.

What I believe I need to do is:

1) Set up a new distribution group using the Exchange Management Console. Let's say this new distribution group (which appears in the list of Distribution Groups under Recipient Configuration) is called "FloridaBar".

2) Make sure I have a csv file of the information I want to import.

3) Open Exchange Management Shell, and enter the following command:

Import-csv C:\filename.csv | ForEach-Object { New-MailContact -Name 

$."NameColumnName" -ExternalEmailAddress $."EmailAddressColumn" -org FloridaBar

Now, creating 1,000+ contacts in active directory – I assume that shouldn't be an issue.

Do I have the "-org" parm wrong? Do I need to spell out the complete organization unit name (my.domain.name/Users/FloridaBar)?

Is there a better way of doing this?

Thanks in advance

Ken

Best Answer

The -org switch is the OrganizationalUnit to place the new contact in, not the name of the group.

You need something like the following (enter it all on one line - I have split it solely for readability).

Import-CSV -Path D:\contacts.csv | 
ForEach-Object { 
New-MailContact -Name $_.Name -ExternalEmailAddress $_.ExternalEmailAddress 
-OrganizationalUnit "cn=Users,dc=Adatum,dc=com"; 
Add-DistributionGroupMember -Identity "FloridaBar" -Member $_.Name }

In this case, my contacts.csv has two columns - Name and ExternalEmailAddress.

The distribution group FloridaBar must be created before the import.

Note: If this were to be used more than once then I would put some effort into error handling; probably by writing a ps1 script that looped through the collection and write erroneous data (for example names that already existed in AD) out to an errors.csv file.

Related Topic