Admin/Technician/New-SDPTechnician.ps1

Function New-SDPTechnician
{
    <#
    .SYNOPSIS
        Add new Technician
 
    .PARAMETER InputData
        Input data as hashtable or JSON string
 
    .EXAMPLE
        $InputData = @{
            "technician"= @{
                    "first_name" = "Michal"
                    "last_name" = "Gajda"
                    "name" = "Michal Gajda"
                    "email_id": "mgajda@sdpexample.pl"
            }
        }
 
        $User = New-SDPTechnician -InputData $InputData
 
    .NOTES
        Author: Michal Gajda
 
    .LINK
        https://ui.servicedeskplus.com/APIDocs3/index.html#add-a-technician
    #>

    [CmdletBinding(
        SupportsShouldProcess=$True,
        ConfirmImpact="Low"
    )]
    param (
        [String]$UriSDP,
        [String]$ApiKey,
        [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 = "POST"
            EntityUri = "/api/v3/technicians"
            InputData = $InputData
        }

        #Send request
        If ($PSCmdlet.ShouldProcess($InputData.technician.name,"Add new technician"))
        {
            $Result = Invoke-SDPAPIEntity @InvokeParams
            $Results = $Result.technician
        }

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

    End{}
}