Functions/Update-TicketStatus.ps1

#Install-Module PSGraphQL
Import-Module PSGraphQL

function Update-TicketStatus {
    Param(
         [Parameter(Mandatory=$true, Position= 0)][Alias("CustomerSubDomain", "Domain", "CustomerDomain")][String]$SubDomain,
         [Parameter(Mandatory=$true, Position= 1)][Alias("api_key", "API-KEY", "key")][String]$ApiKey,
         [Parameter(Mandatory=$true, Position= 2)][Alias("ticId", "id", "ti")][Long]$ticketId,
         [Parameter(Mandatory=$true, Position= 3)][Alias("st")][String]$status
         )
     
    $uri = "https://api.superops.ai/msp"
    
    $status = '"'+$status+'"' # Format to GraphQL schema

    $Mutation = "
    mutation{
    updateTicket(input: {
            ticketId: $ticketId,
            status: $status
         }){
        ticketId
        displayId
        subject
        ticketType
        source
        client
        site
        requester
        additionalRequester
        technician
        status
        approvalStatus
        priority
        sla
        customFields
        }
    }
    "


    Write-Host $Mutation

    $requestHeaders = @{'CustomerSubDomain'=$SubDomain; 'Authorization'= $apiKey}
    $jsonResult = Invoke-GraphQLQuery -Query $Mutation -Headers $requestHeaders -Uri $Uri -Raw

    Write-Host $jsonResult
}