Skip to content

Instantly share code, notes, and snippets.

@Subtixx
Created January 20, 2022 15:51
Show Gist options
  • Save Subtixx/a2d4fc8b20f221cfd12f1166d58869dc to your computer and use it in GitHub Desktop.
Save Subtixx/a2d4fc8b20f221cfd12f1166d58869dc to your computer and use it in GitHub Desktop.
Import Contacts to Office365
param (
[Parameter(mandatory=$true)]
[string]$principal,
[Parameter(mandatory=$true)]
[string]$name,
[Parameter(mandatory=$true)]
[string]$email,
[Parameter(mandatory=$true)]
[string]$firstname,
[Parameter(mandatory=$true)]
[string]$lastname
)
Import-Module ExchangeOnlineManagement
#Connect-ExchangeOnline -InlineCredential
Connect-ExchangeOnline -UserPrincipalName $principal
New-MailContact -Name $name -DisplayName $name -ExternalEmailAddress $email -FirstName $firstname -LastName $lastname
Disconnect-ExchangeOnline -Confirm:$false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment