Share via


O365: Bulk import of Contacts

In Office 365 we can easily import contacts from a CSV file vs. having to create them 1 by 1. The first step in doing so is to connect to our Tenant using Azure PowerShell. To do this launch Azure PS as Administrator and you should get a window as shown below.

https://collaborationpro.com/wp-content/uploads/2016/08/Launch-Azure-PS-300x167.png

The next step is to do the following:

  • Import-Module MSOnline
  • $UserCredential = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

https://collaborationpro.com/wp-content/uploads/2016/08/Import-Modules-300x167.png

Once we run the second command it will prompt for user credentials. Enter your login info for O365 and click OK. You will be taken back to a prompt.

https://collaborationpro.com/wp-content/uploads/2016/08/Import-Exchange-Modules-300x167.png

 

After we enter in the third and then fourth command you will see the commands importing in O365.

 

https://collaborationpro.com/wp-content/uploads/2016/08/Contacts-blank-300x112.png

 

If we log into the Office Admin Center and expand Users -> Contacts we can see that we have no contacts listed for our domain. To import contacts from a CSV file we can run the command below:

https://collaborationpro.com/wp-content/uploads/2016/08/Create-multiple-contacts-300x158.png

This is the command run:

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

You can just change the file path to where your CSV file is stored.

https://collaborationpro.com/wp-content/uploads/2016/08/Successfully-run-script-300x158.png

Once successfully run, it will take a few minutes depending on the number of contacts to create. You should be returned back to the prompt when done. If a contact does exist then you will receive red lines with errors saying the contact exists.

https://collaborationpro.com/wp-content/uploads/2016/08/Contacts-visible-o365-300x107.png

If we refresh our contacts list, you can now see the ones that were imported.

From the Office Admin Center you cannot perform bulk options on contacts. If you want to delete all you should use the Shell vs the GUI.