Admin/Technician/Set-SDPTechnicianAsUser.ps1

Function Set-SDPTechnicianAsUser
{
    <#
    .SYNOPSIS
        Change Technican as User
 
    .PARAMETER TechnicianId
        Technician id
 
    .EXAMPLE
        $Status = Set-SDPTechnicianAsUser -TechnicianId 54321
 
    .NOTES
        Author: Michal Gajda
 
    .LINK
        https://ui.servicedeskplus.com/APIDocs3/index.html#change-as-user
    #>

    [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/change_as_user?ids=$TechnicianId"
        }

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

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

    End{}
}