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, you should get a window as shown below.

Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 1

The next step is to do the following:

  • Import-Module MSOnline
  • $UserCredential = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://wwwoutlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session
Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 2

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

Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 3

After we enter in the 3rd and then 4th command you will see the commands importing in O365.

Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 4
Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 5

If we login to 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:
This is the command run:

  • $New = Import-Csv C:\ExternalContacts.csv|%{New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}
Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 6
Office 365 - bulk import of contacts
Office 365 - Bulk import of Contacts 7

You can just change the file path to where your CSV file is stored.
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.

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 wanted to delete all you would rather use the Shell vs the GUI.

Hope it helps.

Discover more from COLLABORATION PRO

Subscribe now to keep reading and get access to the full archive.

Continue reading