Update external contact lis in exchange using powershell

hi,

How do we update the existing external contcts in exchange? 1st import was last year and we have a new csv contact list.

I have this in mind:

A. Delete all outdated external contact

start Exchange Management Shell and run the following script:

Get-Contact | Remove-MailContact

B. Import updated external contact

-Import  .csv file with the desired contacts, set column headings as follows: Alias, DisplayName, Name, EmailAddress

-save the file as contacts.csv and copy the file to the server.

-start Exchange Management Shell and run the following script:

import-Csv "C:Contacts.csv" | ForEach-Object{

$displayname=$_.DisplayName

New-MailContact -Name $_.Name -ExternalEmailAddress $_.EmailAddress -Alias $_.Alias

}

But on our CSV file we have other parameters as follows:

  • last name
  • First name
  • Job title
  • Display name
  • company
  • Department
  • Branch
  • Phone
  • Email Address

Will my plan work?

How will the missing parameters be reflected when we import?

thanks


  • Edited by MGerio 22 hours 2 minutes ago
July 15th, 2015 5:26am

Hi,

Q."Will my plan work?"

Please test it out using some test contacts, you will figure on your own that if it works or not.

How do you identify existing contacts, does the new and old data have anything in common.

If your data is stale, its good to delete and update again, but might comeup with OAB cached contacts issues sometimes.

Best option is to Identify the existing contacts and update them.

Use the Set-MailContact cmdlet to modify an existing mail-enabled contact in Active Directory.

Q."How will the missing parameters be reflected when we import?"

Only the mapped ones will reflect, remaining will be skipped.

Refer this Bulk-create external contacts in Exchange Online:

https://community.office365.com/en-us/w/exchange/5

July 15th, 2015 6:08am

Hi,

For Q1, I agree with Satyajit321.

For Q2, we can add the set-contact in the script to configure the other parameters that not exist under New-MailContact cmdlet. My  edited script for reference.

Import-Csv "C:\Contacts.csv" | ForEach-Object{

New-MailContact -Name $_.Name -ExternalEmailAddress $_.EmailAddress -Alias $_.Alias -displayname $_.DisplayName

Set-Contact $_.Alias Firstname $_.Firstname LastName $_.LastName Title $_.JobTitle DisplayName $_.DisplayName Company $_.Company Department $_.Department Phone $_.Phone -ExternalEmailAddress $_.EmailAddress

}

Best Regards.

July 15th, 2015 11:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics