ConnectWise Automate Extra Data Fields

I’ve modified the built-in functions for retrieving EDFs from Automate since I got frustrated quickly when trying to use them. The main issue is the current functions only return a value if the EDF type is text, and fails if it is a dropdown or checkbox. There is no built-in function for retrieving location EDFs which I have used heavily in the past, but this may be intentional since it requires modifying the ImmyBot user permissions in Automate.

There are plenty of improvements that could be made to this, but this at least got it in a usable state for me.

Get-EDFClient

param(
    [string]$FieldName,
    $Computer
)

if(!$Computer)
{
    $Computer = Get-ImmyComputer
}

$RmmInfo = Get-RmmInfo -ProviderType CWAutomate -IncludeClients
$RmmClientId = $RmmInfo.Clients | ?{$_.TenantId -eq $Computer.TenantId} | select -Expand ClientId
$Uri = "cwa/api/v1/clients/$RmmClientId/extrafields"
$RmmEdf = Invoke-CWARestMethod $Uri -Provider $RmmInfo.Provider -QueryParams $QueryParams | ?{$_.Title -like $FieldName}
switch ($RmmEdf.PSObject.Properties.Name){
    "TextFieldSettings" {
        $RmmEdf.TextFieldSettings | select -expand Value
    }
    "DropdownSettings" {
        $RmmEdf.DropdownSettings | select -expand SelectedValue
    }
    "CheckboxSettings" {
        $RmmEdf.CheckboxSettings | select -expand IsChecked
    }
}

Get-EDFComputer

param(
    [string]$FieldName,
    $Computer
)

if(!$Computer)
{
    $Computer = Get-ImmyComputer
}

$RmmInfo = Get-RmmInfo -ProviderType CWAutomate
$RmmComputer = Get-RmmComputer -Computer $Computer -ProviderType CWAutomate
$Uri = "cwa/api/v1/computers/$($RmmComputer.RmmDeviceId)/extrafields"
$RmmEdf = Invoke-CWARestMethod $Uri -Provider $RmmInfo.Provider -QueryParams $QueryParams | ?{$_.Title -like $FieldName}
switch ($RmmEdf.PSObject.Properties.Name){
    "TextFieldSettings" {
        $RmmEdf.TextFieldSettings | select -expand Value
    }
    "DropdownSettings" {
        $RmmEdf.DropdownSettings | select -expand SelectedValue
    }
    "CheckboxSettings" {
        $RmmEdf.CheckboxSettings | select -expand IsChecked
    }
}

Get-EDFLocation
*Requires granting “location read” user class permissions for each Automate client.

param(
    [string]$FieldName,
    $Computer
)

if(!$Computer)
{
    $Computer = Get-ImmyComputer
}

$RmmInfo = Get-RmmInfo -ProviderType CWAutomate
$RmmComputer = Get-RmmComputer -Computer $Computer -ProviderType CWAutomate
$Uri = "/cwa/api/v1/computers?condition=Id='$($RmmComputer.RmmDeviceId)'&includeFields=Location"
$RmmLocation = Invoke-CWARestMethod $Uri -Provider $RmmInfo.Provider | select -expand Location
$Uri = "/cwa/api/v1/locations/$($RmmLocation.Id)/ExtraFields"
$RmmEdf = Invoke-CWARestMethod $Uri -Provider $RmmInfo.Provider -QueryParams $QueryParams | ?{$_.Title -like $FieldName}
switch ($RmmEdf.PSObject.Properties.Name){
    "TextFieldSettings" {
        $RmmEdf.TextFieldSettings | select -expand Value
    }
    "DropdownSettings" {
        $RmmEdf.DropdownSettings | select -expand SelectedValue
    }
    "CheckboxSettings" {
        $RmmEdf.CheckboxSettings | select -expand IsChecked
    }
}

1 Like

Which permissions did you have to modify in Automate?