How to i enter hebrew characters in New-MailContact (CSV bulk import)

GreatSolutions
GreatSolutions used Ask the Experts™
on
Hi
I am trying to run a bulk import to my Exchange 2010 from a CSV file.
I run the following in a powershell script:

Import-Csv C:\contacts.csv | ForEach { New-MailContact -Name $_.displayName -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.EmailAddress -OrganizationalUnit "YourDomain.Local/Contacts"

It runs great, but the problem is that the CSV file has hebrew characters, and those are entered as question marks instead. Is there some setting i am missing?

Thanks
Jaime
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Infrastructure Architect
Commented:
The problem is that the .csv file was saved in the ANSI format. You can fix this by converting the file to unicode with the following comand before importing.

gc c:\old-file.csv | Out-File -en unicode c:\new-unicode.csv

Or you can just open the csv file in notepad and save it in unicode format before you run import-csv..
Unicode

Author

Commented:
Thanks, it does load the hebrew characters alright, although the Alias field is filled with question marks for all contacts, is there something i can do?

Author

Commented:
Easy to implement and saved me hours of fiddling with the encoding...
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Subash SundharanIT Infrastructure Architect

Commented:
Do you have problem after changing the encoding? if yes please post some sample words/usernames which you have issue, so I will test it..

Author

Commented:
I think i didn't explain well.
I opened the csv file and saved it as Unicode.
Then i run the import code from my first post, and it runs successfully, and when checking, all the contacts were created successfully *with correct hebrew characters*.
Just when browsing the contacts themselves, i noticed the Alias field (which is created automatically i guess, during the import ) is all question marks. I wondered if there was a way for me to set the value for this field so it's in hebrew as well.

Jaime
Subash SundharanIT Infrastructure Architect

Commented:
If you have a list of contacts to modify, then you can try with set mailbox.. Something like the following should work..
Import-csv "c:\newalias.csv" | % {Get-MailContact - Identity $_.Name | Set-MailContact -Alias $_.Alias}

Open in new window

Author

Commented:
I'll try that, thanks!
Subash SundharanIT Infrastructure Architect

Commented:
then you can try with set mailbox..
I mean Set-MailContact.. it's a typo.. :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial