Skip to content

Instantly share code, notes, and snippets.

@davejlong
Last active April 21, 2021 20:32
Show Gist options
  • Save davejlong/713d61e03fe679afc9e31654a4036a2e to your computer and use it in GitHub Desktop.
Save davejlong/713d61e03fe679afc9e31654a4036a2e to your computer and use it in GitHub Desktop.
Import users from Azure into Atera as contacts under a specified customer.
###
# Author: Dave Long <[email protected]>
# Date: 2021-04-21
#
# Imports users from Microsoft 365 into Atera Contacts
###
$AteraCustomerID = "<ATERA CUSTOMER ID>"
$AteraAPIKey = "<ATERA API KEY>"
## Uncomment the below lines if you do not have PSAtera and Exchange Online PowerShell V2 Module installed
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityPotocol -bor 3072
# Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
# Install-Module -Name PSAtera -Force
# Install-Module -Name AzureAD -Force
# Load in the necessary modules
Import-Module -Name PSAtera
Import-Module -Name AzureAD
# Configure PSAtera
Set-AteraAPIKey -APIKey $AteraAPIKey
# Connect to Azure AD
Connect-AzureAD
# Get a list of all users
$Users = Get-AzureADUser
foreach($User in $Users) {
if ($User.Mail -eq "") { return }
$ContactInfo = @{
CustomerID = $AteraCustomerID
Email = $User.Mail
FirstName = $User.GivenName
LastName = $User.SurName
JobTitle = $User.JobTitle
Phone = $User.TelephoneNumber
}
New-AteraContact @ContactInfo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment