Last active
April 21, 2021 20:32
-
-
Save davejlong/713d61e03fe679afc9e31654a4036a2e to your computer and use it in GitHub Desktop.
Import users from Azure into Atera as contacts under a specified customer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# 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