0

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

2 Answers 2

1

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.

0

I just found something that probably would have helped you from here.

Scenario: Create a distribution group and add mailboxes specified by a CSV file to the distribution group

Shell one-liner:

Below one-liner creates a distribution group for all team members based on Avalanche.csv file, which contains NHL Avalanche team roster information including the below columns: Pos,No,Player,Age,Ht,Wt,Born,Exp,Birth City

new-distributiongroup -alias avalanche -name "Avalanche Team" -type distribution -org users -SamAccountName AvalancheTeam import-csv Avalanche.csv | foreach {add-distributiongroupmember avalanche -member "avalanche$($_.No)"}

1
  • Don't you need to create the mail contact before you try and add it to the distribution group?
    – john
    Jul 1, 2013 at 20:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .