Import Multiple Contacts from vCard Files in Office 365 Exchange Online

Introduction

This script demonstrates how to import multiple contacts from vCard files in Office 365 Exchange Online. You can choose to import a single vCard file or multiple vCard files with this script.

Scenario

Currently Outlook Web App supports to import a .CSV file only. You need to find a solution to convert vCard files to a csv file when migrating from another email service providers or solutions. So you want to use a script to mitigate this problem.

Prerequisite

This script requires Exchange Web Service Managed API 2.0. Please download and install the package from Microsoft Download Center. This script cannot work correctly without this package.

Script

This script contains the following advanced functions:

You can use this script in the following way.

  1. Open Windows PowerShell.
  2. Run Import-Module cmdlet to import this module file.
    Import-Module filepath\scriptname.psm1

 Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

PowerShell
Edit|Remove
#Get vCard files from specified pathTry 
{ 
    if (Test-Path-Path $Path-PathType Container) { 
        $vcardFiles = Get-ChildItem-Path $Path-Filter*.vcf -ErrorAction Stop 
    } else { 
        $vcardFiles = Get-ChildItem-Path $Path-ErrorAction Stop 
    } 
} 
Catch 
{ 
    $PSCmdlet.ThrowTerminatingError($_) 
} 

Examples

Example 1: How to display help about Import-OSCEXOVCardFile.
To display help about this function, run this command.
Get-Help Import-OSCEXOVCardFile -Full

Example 2: How to initiate a connection to Office 365 Exchange Online.
To initiate a connection to Office 365 Exchange Online, please run this command. You must run this example before any other step.
Connect-OSCEXOWebService -Credential (Get-Credential admin@domain01.onmicrosoft.com)

Note The Connect-OSCEXOWebService function creates a new variable called exService. This variable is in the global scope of the current Windows PowerShell session. This variable is used by other functions in the script.

Example 3: How to import vCard files to create contact John Doe (johnd) in Office 365 Exchange Online.
To import vCard files to create contact John Doe (johnd) in Office 365 Exchange Online, please run this command.
Import-OSCEXOVCardFile -Path C:\Scripts\071\vCards\johnd.vcf

Example 4: How to import vCard files to create multiple contacts in Office 365 Exchange Online.
To import vCard files to create multiple contacts in Office 365 Exchange Online, please run this command.
Import-OSCEXOVCardFile -Path C:\Scripts\071\vCard

Note The Import-OSCEXOVCardFile only supports vCard version 2.1 files.

Additional Resources

Technical Resources:
Windows PowerShell Advanced Function
Creating contacts by using the EWS Managed API

Forum Threads:
http://community.office365.com/en-us/forums/158/t/47877.aspx 
http://community.office365.com/en-us/forums/158/t/80261.aspx