Link to home
Start Free TrialLog in
Avatar of NickMeyrick
NickMeyrick

asked on

Bulk import from a CSV file into Exch 2007 Mail Contacts

I can import name and e-mail info but not the phone number - I assume this has to be a 2 pass operation - can anyone help me with a sample script to achieve this please?
The script immediately below achieves the basic first pass:
import-csv c:\bcbc.csv | foreach { new-mailcontact -Name $_.displayName -Firstname $_.Firstname -Lastname $_.Lastname -ExternalEmailAddress $_.EmailAddress -org "<mydomain.com/contacts>"}
But if I try to append a Set-Contact command in the same script using the command Set-Contact $_.displayName -Phone $_.Telephone}
it fails - so my unsuccessful script looks like:
import-csv c:\bcbc.csv | foreach { new-mailcontact -Name $_.displayName -Firstname $_.Firstname -Lastname $_.Lastname -ExternalEmailAddress $_.EmailAddress -org "<mydomain.com/contacts>" Set-Contact $_.displayName -Phone $_.Telephone}
Avatar of Alan Hardisty
Alan Hardisty
Flag of United Kingdom of Great Britain and Northern Ireland image

If you issue a 'help import-csv' command from the Exchange Shell, you will see that there is no Set-Contact option, which is why it is failing.
ASKER CERTIFIED SOLUTION
Avatar of Alan Hardisty
Alan Hardisty
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickMeyrick
NickMeyrick

ASKER

Yes - initial commnet was a bit misleading on first read but the second post to the sample script was good and enabled me to get the import working- thanks