iMPORT-CSV ERROR

Hi

i'm trying to import new mail contact from .csv file,  by this command in exchange 2010 powershell

Import-Csv  c:\name.csv | foreach  {new-mailcontact  -name  $_.name  -externalemailaddress  $_.emailaddress;set-contact  –Alias $_.alias  -identity  $_.name  -office  $_.office  -department  $_.department}

but the system returns the following error:

[PS] C:\>Import-Csv  c:\name.csv | foreach  {new-mailcontact  -name  $_.name  -externalemailaddress  $_.emailaddress;set
-contact  -Alias $_.alias  -identity  $_.name  -office  $_.office  -department  $_.department}
The term 'Import-Csv ' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
 spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:12
+ Import-Csv  <<<<  c:\name.csv | foreach  {new-mailcontact  -name  $_.name  -externalemailaddress  $_.emailaddress;set
-contact  -Alias $_.alias  -identity  $_.name  -office  $_.office  -department  $_.department}
    + CategoryInfo          : ObjectNotFound: (Import-Csv :String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Any IDEA?

thanks
Leonardo StorelliAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
My guess is you didn't actually type the line, but copied and pasted it from somewhere else, either a website or some word processor (as opposed to a text editor). These have a tendency to replace the real minus "-" (ASCII 45) with a pretty hyphen (like ASCII 150 or 151).
Paste the line into the console again, but before you hit Enter, edit the line and delete and retype each and every "-".
MASEE Solution Guide - Technical Dept HeadCommented:
create a CSV file in the below format. This does not have department and office
name           emailaddress                    alias      
Mike Witts     Mike.Witts@n.com     mike.witts  
John Smith    John.Smith@n.com     john.witts  


and  try this command and post the result
 
Import-Csv c:\name.csv | foreach {new-mailcontact  -name  $_.name  -externalemailaddress  $_.emailaddress –Alias $_.alias}

Open in new window


Try with couple of users first
Leonardo StorelliAuthor Commented:
Hi

I created the CSV file in this format:

COLUMN A
----------------------------------------------------------------------------------------------------------------------------------------------
1 Name, emailaddress, Alias, office, department
2 Stephen King, stephen @ king.com, stephenking, press, IT

the result of command

[PS] C:\>new-mailcontact  -name  "Chris Ashton"  -externalemailaddress   "Chris@tailspintoys.com" ;set-contact  -Alias "ashton" -office  "press"  -department  "IT"
Name                      Alias                                          RecipientType
----                      -----                                          -------------
Chris Ashton              ChrisAshton                                    MailContact
A positional parameter cannot be found that accepts argument 'ashton'.
    + CategoryInfo          : InvalidArgument: (:) [Set-Contact], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Set-Contact
oBdACommented:
Set-Contact doesn't have an argument "Alias".
Set-Contact
https://technet.microsoft.com/en-us/library/bb124535(v=exchg.141).aspx

Since you've gotten so far, I guess the initial issue with the Import-Csv is resolved?
Leonardo StorelliAuthor Commented:
Hi

hi, I solved the problem by removing the field " Alias ​​" , because I think , external contacts do not need the alias

Thamk you

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.