Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating Mail Contacts from CSV Exchange 2010 Powershell Command

Posted on 2014-01-30
3
Medium Priority
?
4,289 Views
Last Modified: 2014-01-30
I'm using the below command to create a new mail contact in AD, but it's throwing an error.  It works in a 2008 Active Directory environment, but not on 2003 Active Directory, and it seems to get an error at the Set-Contact -identity portion:

The script is:

Import-CSV C:\adexport.csv | ForEach-Object{
New-MailContact -ExternalEmailAddress $_.mail -Name $_.Name -OrganizationalUnit $_.OUpath
Set-Contact -identity $_.Name -Phone $_.telephoneNumber -MobilePhone $_.Mobile -Office $_.physicalDeliveryOfficeName -Title $_.Title -Department $_.Department
}

The error message i'm getting is:

Error message
0
Comment
Question by:fireguy1125
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Expert Comment

by:footech
ID: 39820998
The error appears to be because it thinks Set-Contact is part of the New-Contact command.
Are you sure they are on separate lines and that there is no line continuation character (backtick "`") at the end of the New-Contact command?
You can also try putting a semi-colon at the end of the New-Contact command.
0
 
LVL 1

Author Comment

by:fireguy1125
ID: 39821022
It's all within {}  Can you provide the script I should try please?
0
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 39821215
The commands appear correct from what you have above.  I was just explaining what the error is indicating (and I just realized I incorrectly referred to New-MailContact as New-Contact).
I see no reason why the following wouldn't work on any system.
Import-CSV C:\adexport.csv | ForEach-Object{
New-MailContact -ExternalEmailAddress $_.mail -Name $_.Name -OrganizationalUnit $_.OUpath
Set-Contact -identity $_.Name -Phone $_.telephoneNumber -MobilePhone $_.Mobile -Office $_.physicalDeliveryOfficeName -Title $_.Title -Department $_.Department
}

Open in new window

but like I said, you can try adding a semi-colon
Import-CSV C:\adexport.csv | ForEach-Object{
New-MailContact -ExternalEmailAddress $_.mail -Name $_.Name -OrganizationalUnit $_.OUpath;
Set-Contact -identity $_.Name -Phone $_.telephoneNumber -MobilePhone $_.Mobile -Office $_.physicalDeliveryOfficeName -Title $_.Title -Department $_.Department
}

Open in new window

1

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question