endpoints/CustomValues.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

<#
  .Synopsis
  Get the value from a custom field in Atera
   
  .Parameter ObjectType
  The type of object to query against. Options: Ticket, Customer, Contact, Contract, SLA, Agent, SNMP, TCP, HTTP, Generic
 
  .Parameter ObjectID
  The ID of the object to query (ex. Ticket ID)
 
  .Parameter FieldName
  The name of the customer field
   
  .Example
  Get-AteraCustomValue -ObjectType Ticket -ObjectID 1234 -FieldName "Scheduled For"
  # Get the "Scheduled For" field for Ticket 1234
#>

function Get-AteraCustomValue {
  [CmdletBinding()]
  param (
    [Parameter(Mandatory)]
    [ValidateSet("Ticket", "Customer", "Contact", "Contract", "SLA", "Agent", "SNMP", "TCP", "HTTP", "Generic")]
    [string] $ObjectType,
    [Parameter(Mandatory)]
    [int] $ObjectID,
    [Parameter(Mandatory)]
    [string] $FieldName
  )
  $FieldName = [uri]::EscapeDataString($FieldName)
  $uri = "/customvalues/$($ObjectType.ToLower())field/$ObjectID/$FieldName"
  New-AteraGetRequest -Endpoint $uri -Paginate $false
}