Admin/Technician/Set-SDPTechnician.ps1

Function Set-SDPTechnician
{
    <#
    .SYNOPSIS
        Update Technician
 
    .PARAMETER TechnicianId
        Technician id
 
    .PARAMETER InputData
        Input data as hashtable or JSON string
 
    .EXAMPLE
        $InputData = @{
            "technician"= @{
                    "first_name" = "Michal"
                    "last_name" = "Gajda"
                    "name" = "Michal Gajda"
            }
        }
 
        $Technician = Set-SDPTechnician -TechnicianId 54321 -InputData $InputData
 
    .NOTES
        Author: Michal Gajda
 
    .LINK
        https://ui.servicedeskplus.com/APIDocs3/index.html#update-a-technician
    #>

    [CmdletBinding(
        SupportsShouldProcess=$True,
        ConfirmImpact="Low"
    )]
    param (
        [String]$UriSDP,
        [String]$ApiKey,
        [Parameter(Mandatory=$true,
            ValueFromPipeline)]
        [Int]$TechnicianId,
        [Parameter(Mandatory=$true)]
        $InputData
    )

    Begin
    {
        #Create headers
        if(!$MyInvocation.BoundParameters.ContainsKey("UriSDP")) { $UriSDP = $Global:UriSDP }
        if(!$MyInvocation.BoundParameters.ContainsKey("ApiKey")) { $ApiKey = $Global:ApiKey }
    }

    Process
    {
        $InvokeParams = @{
            UriSDP = $UriSDP
            ApiKey = $ApiKey
            Method = "PUT"
            EntityUri = "/api/v3/technicians/$TechnicianId"
            InputData = $InputData
        }

        #Send request
        If ($PSCmdlet.ShouldProcess($TechnicianId,"Update technician by id"))
        {
            $Result = Invoke-SDPAPIEntity @InvokeParams
            $Results = $Result.technician
        }

        #Return result
        if($MyInvocation.BoundParameters.ContainsKey("Debug"))
        {
            Return $Result
        } else {
            Return $Results
        }
    }

    End{}
}