Importing Office 365 contacts en mass using Power Shell


One of the less pleasant parts of my role is adding people to distribution lists….

The Office365 UI certainly doesn’t make this easy!

Turns out it is pretty easy with Power Shell..

Saving all my contacts to a CSV you can add contacts en mass using the following commands:

 

$cred = Get-Credential
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
$importresults = Import-PSSession $s

$Contacts = Import-CSV .\contacts.csv

 

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

$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}


Comments (1)

  1. SimorC says:

    Well, simple enough.

Skip to main content