endpoints/Contacts.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

<#
  .Synopsis
  Get list of contacts from API
#>

function Get-AteraContacts {
  return New-AteraGetRequest -Endpoint "/contacts"
}

<#
  .Synopsis
  Get a single contact by it's ID
   
  .Parameter ContactID
#>

function Get-AteraContact {
  param (
    [Parameter(Mandatory)]
    [int] $ContactID
  )
  return New-AteraGetRequest -Endpoint "/contacts/$ContactID"
}

<#
  .Synopsis
  Create a contact attached to a customer
  .Parameter CustomerID
 
  .Parameter CustomerName
 
  .Parameter Email
 
  .Parameter FirstName
 
  .Parameter LastName
 
  .Parameter JobTitle
 
  .Parameter Phone
 
  .Parameter IsContactPerson
  Mark this contact as a key contact for the customer
 
  .Parameter InIgnoreMode
  Ignore emails from this contact
 
  .Example
  Get-AzureADUser | ForEach-Object {
    New-AteraContact -CustomerName "Contoso" -Email $_.Mail -FirstName $_.GivenName -LastName $_.Surname -Phone $_.TelephoneNumber -JobTitle $_.JobTitle
  }
  # Imports all Azure AD users into Atera
#>

function New-AteraContact {
  [CmdletBinding(DefaultParameterSetName='ByCustomerID')]
  param (
    [Parameter(Mandatory, ParameterSetName='ByCustomerID')]
    [int] $CustomerID,
    [Parameter(Mandatory, ParameterSetName='ByCustomerName')]
    [string] $CustomerName,
    [Parameter(Mandatory)]
    [string] $Email,
    [Parameter()]
    [string] $FirstName,
    [Parameter()]
    [string] $LastName,
    [Parameter()]
    [string] $JobTitle,
    [Parameter()]
    [string] $Phone,
    [Parameter()]
    [switch] $IsContactPerson,
    [Parameter()]
    [string] $InIgnoreMode
  )
  New-AteraPostRequest -Endpoint "/contacts" -Body $PSBoundParameters
}