Skip to content

Instantly share code, notes, and snippets.

@davejlong
Last active April 21, 2021 20:32
Show Gist options
  • Select an option

  • Save davejlong/713d61e03fe679afc9e31654a4036a2e to your computer and use it in GitHub Desktop.

Select an option

Save davejlong/713d61e03fe679afc9e31654a4036a2e to your computer and use it in GitHub Desktop.

Revisions

  1. davejlong revised this gist Apr 21, 2021. 1 changed file with 36 additions and 6 deletions.
    42 changes: 36 additions & 6 deletions Import-CustomerContacts.ps1
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,40 @@
    Import-Module PSAtera
    Import-Module AzureAD
    ###
    # Author: Dave Long <[email protected]>
    # Date: 2021-04-21
    #
    # Imports users from Microsoft 365 into Atera Contacts
    ###

    # Set the Customer ID in the variable below. ID can be found in the URL when you visit the customer page
    $CustomerID = 19
    $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-AzureADUser | Where-Object UserType -eq Member | ForEach-Object {
    New-AteraContact -CustomerID $CustomerID -FirstName $_.GivenName -LastName $_.Surname -JobTitle $_.JobTitle -Email $_.Mail -Phone $_.TelephoneNumber

    # 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
    }
  2. davejlong created this gist Jan 7, 2021.
    10 changes: 10 additions & 0 deletions Import-CustomerContacts.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    Import-Module PSAtera
    Import-Module AzureAD

    # Set the Customer ID in the variable below. ID can be found in the URL when you visit the customer page
    $CustomerID = 19

    Connect-AzureAD
    Get-AzureADUser | Where-Object UserType -eq Member | ForEach-Object {
    New-AteraContact -CustomerID $CustomerID -FirstName $_.GivenName -LastName $_.Surname -JobTitle $_.JobTitle -Email $_.Mail -Phone $_.TelephoneNumber
    }