Solved

import in CSV mail contacts to exchange 2010 to specific OU

Posted on 2014-03-20
7
909 Views
Last Modified: 2014-03-24
Hello,

I am having an issue importing mail contacts to specific ou.  It works when i just do import-csv "filename"  but i need to import in to a specific OU.

IN csv file i have DisplayName, Alias,EmailAddress fields

Thank you
0
Comment
Question by:ymordkovich
[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
  • 3
  • 3
7 Comments
 
LVL 35

Accepted Solution

by:
Joseph Daly earned 250 total points
ID: 39942306
You will want to do something similar to below.

import-csv filename.csv | foreach {new-mailcontact -name $_.csvheading1 -primarysmtpaddress $_.csvheading2 -organizationalunit distinguishednameofou}
0
 

Author Comment

by:ymordkovich
ID: 39942824
I get an error

Cannot bind argument to parameter 'Name' because it is an empty string.
    + CategoryInfo          : InvalidData: (:) [New-MailContact], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-MailContact
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 39942841
Can you past your modified script. Did you change the $_.csvheading1 to the correct column name in your CSV file?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 

Author Comment

by:ymordkovich
ID: 39942872
import-csv .\import1.csv | foreach {new-mailcontact -displayname $_.displayname -primarysmtpaddress $_.emailaddress -organizationalunit ou=newfax,dc=borbas,dc=local}

i get this error

[PS] C:\users\Administrator\desktop>.\import.ps1
Cannot process argument transformation on parameter 'PrimarySmtpAddress'. Cannot convert null to type "Microsoft.Exchan
ge.Data.SmtpAddress".
    + CategoryInfo          : InvalidData: (:) [New-MailContact], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MailContact
0
 
LVL 7

Assisted Solution

by:BT15
BT15 earned 250 total points
ID: 39943042
are you sure you have a column in your csv called 'emailaddress', or that the column has values in it?

your error message is complaining that you are attempting to pass an empty value to the primarysmtpaddress parameter
0
 
LVL 35

Expert Comment

by:Joseph Daly
ID: 39943124
As BT15 stated make sure that the column names match up as well there are no extra characters in the field. The only data that should be in the column is the email address.
0
 

Author Closing Comment

by:ymordkovich
ID: 39950274
Thank you all
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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