Bulk Import Contacts to Office 365 Exchange Online Using PowerShell

Article sections

    Create a CSV file that contains information about the external contacts

    Copy and paste the following into a notepad file and save as a .csv

    ExternalEmailAddress,Name,FirstName,LastName,StreetAddress,City,StateorProvince,PostalCode,Phone,MobilePhone,Pager,HomePhone,Company,Title,OtherTelephone,Department,CountryOrRegion,Fax,Initials,Notes,Office,Manager
    danp@fabrikam.com,Dan Park,Dan,Park,1234 23rd Ave,Golden,CO,80215,206-111-1234,303-900-1234,555-1212,123-456-7890,Fabrikam,Shipping clerk,555-5555,Shipping,US,123-4567,R.,Good worker,31/1663,Dan Park
    pilar@contoso.com,Pilar Pinilla,Pilar,Pinilla,1234 Main St.,Seattle,WA,98017,206-555-0100,206-555-0101,206-555-0102,206-555-1234,Contoso,HR Manager,206-555-0104,Executive,US,206-555-0105,P.,Technical decision maker,31/1000,Dan Park

    Open the .CSV file using excel. The file contain example data which you must remove and replace with your own data

    Delete Row 2 and Row 3

    Create a row for each contact that you want to import to Exchange Online.

     

    Import CSV file that contains information about the external contacts using Powershell

    1. Connect PowerShell to your Exchange Online organization. For step-by-step instructions, see Connect to Exchange Online PowerShell. Be sure to use the user name and password for your Office 365 global administrator account when you connect to Exchange Online PowerShell.

    2. After you connect PowerShell to Exchange Online, go to the desktop folder where you saved the CSV file in Step 1; for example C:\Users\Administrator\desktop.
    3. Run the following command to create the external contacts:

    Import-Csv <Type the path of your folder here i.e c:\list.csv> | ForEach {New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}

    Wait for the list to be added.