Bulk-create external contacts in Exchange Online

Do you have lots of existing business contacts that you want to include in the shared address book in Exchange Online? Or add your contacts as members of distribution groups, just like you can with users inside your company? If so, you can use Windows PowerShell and a CSV (Comma Separated Value) file to bulk import external contacts into Exchange Online. It’s a three-step process:

  1. Create a CSV file that contains information about the external contacts.
  2. Create the external contacts with PowerShell.
  3. Add information to the properties of each external contact with PowerShell.

Step1: Create a CSV file

Download the sample CSV file posted on the Downloads forum on the Office 365 community site. The sample file is actually a .txt file. So open it in Microsoft Excel, and save it as a CSV file. Use commas as the delimiters.

It includes sample data, which you can delete. But don’t delete the first row. It contains all of the properties for the external contacts. Create a row for each contact that you want to import to Exchange Online. Populate as many of the cells as possible. This information will be displayed in the shared address book for each contact.

However, the following parameters (which are the first four columns in the sample CSV file) are required to create an external contact and must be populated:

  • ExternalEmailAddress
  • Name
  • FirstName
  • LastName

When you’re finished preparing the CSV file, copy it to your desktop. Name it ExternalContacts.csv.

Step 2: Create the external contacts

In this step (and the next one), you have to use Windows PowerShell. To connect PowerShell to your Exchange Online organization, see Use Windows PowerShell in Exchange Online.

After you connect PowerShell to your cloud-based organization, run the following command to create the external contacts:

Import-Csv .\ExternalContacts.csv|%{New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}

Note: This command assumes that you are in the desktop directory in PowerShell. For example, C:\Users\Administrator\desktop.

To view the new external contacts, in the Exchange Control Panel, click Users & Groups > External Contacts > Refresh. They also appear in the shared address book in Outlook and Outlook Web App.

Step 3: Add information to the properties of the external contacts

After you run the command in step 2, the external contacts are created, but they don’t contain any of the contact or organization information, which is the information from the most of the cells in the CSV file).

Run the following commands to add the other properties from the CSV file to the external contacts you created:

$Contacts = Import-CSV .\externalcontacts.csv

$contacts | ForEach {Set-Contact $_.Name -StreetAddress $_.StreetAddress -City $_.City -StateorProvince $_.StateorProvince -PostalCode $_.PostalCode -Phone $_.Phone -MobilePhone $_.MobilePhone -Pager $_.Pager -HomePhone $_.HomePhone -Company $_.Company -Title $_.Title -OtherTelephone $_.OtherTelephone -Department $_.Department -Fax $_.Fax -Initials $_.Initials -Notes $_.Notes -Office $_.Office -Manager $_.Manager}

Don’t worry if you don’t have all the information populated in the CSV file. If it’s not there, it won’t be added.

Note: The Manager parameter can be problematic. If the cell is blank in the CSV file, you will get an error and none of the property information will be added to the contact. If you don’t need to specify a manager, then just delete –Manager $_.Manager from the previous PowerShell command.

That’s it. You can view the contact properties in the Exchange Control Panel. Users can see the contacts in the address book Outlook and Outlook Web App.

Adding more external contacts

You can repeats steps 1 through 3 to add new external contacts in Exchange Online. You or users in your company can just add a new row in the CSV file for the new contact. Then you can run the PowerShell commands from steps 2 and 3 to create and add information to the properties of the new contacts.

Note: When you run the command to create new contacts, you will get errors saying that the contacts that were created earlier already exist. But any new contact added to the CSV file is created.

Hide external contacts from the shared address book

Some companies may use external contacts only so they can be added as members of distribution groups. In this scenario, they may want to hide external contacts from the shared address book. Here’s how:

Hide a single external contact

Set-MailContact <external contact> -HiddenFromAddressListsEnabled $true

For example, to hide Franz Kohl from the shared address book:

Set-MailContact “Franz Kohl” -HiddenFromAddressListsEnabled $true

Hide all external contacts

Run the following command to hide all external contacts from the shared address book:

Get-Contact -ResultSize unlimited -Filter {(RecipientTypeDetails -eq ‘MailContact’)} | Set-MailContact -HiddenFromAddressListsEnabled $true

After you hide them, external contacts aren’t displayed in the shared address book, but you can still add them as members of a distribution group.

For more information about external contacts in Exchange Online, see:

Advertisements

One Comment Add yours

  1. Ӏ visited ѕeveral web рages Һowever thе audio quality
    foг audio songs current ɑt thiѕ website is reɑlly fabulous.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s