Skip to content

Instantly share code, notes, and snippets.

@jdmills-edu
Last active September 20, 2017 19:53
Show Gist options
  • Save jdmills-edu/00795693110c156bba622e808191d452 to your computer and use it in GitHub Desktop.
Save jdmills-edu/00795693110c156bba622e808191d452 to your computer and use it in GitHub Desktop.
A PowerShell script that changes the status of a Zendesk ticket.
param(
[Parameter(Mandatory=$true)][Int32]$ticketID,
[Parameter(Mandatory=$true)][ValidateSet('open', 'pending', 'on-hold', 'solved')][String]$ticketStatus
)
#Zendesk API Connection Headers Referencing System Environmental Variables for username and API token.
$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($ZendeskAPI_Username):$($ZendeskAPI_Token)"));}
#Zendesk API: Update Ticket
$uri = "https://yourdomain.zendesk.com/api/v2/tickets/$ticketID.json"
$json = '{
"ticket": {
"status": "'+$ticketStatus+'"
}
}'
Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -ContentType "application/json" -Body $json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment