Skip to content

Instantly share code, notes, and snippets.

@jdmills-edu
Last active September 20, 2017 19:15
Show Gist options
  • Save jdmills-edu/1b2812a5d5d77173480a6dd69ddda190 to your computer and use it in GitHub Desktop.
Save jdmills-edu/1b2812a5d5d77173480a6dd69ddda190 to your computer and use it in GitHub Desktop.
A PowerShell script that returns a Zendesk ticket of a given ID.
param(
[Parameter(Mandatory=$true)][Int32]$ticketID
)
#Zendesk API Connection Headers Referencing System Environmental Variables for username and API token.
$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($env:ZendeskAPI_Username):$($env:ZendeskAPI_Token)"));}
$ticketsURI = "https://yourdomain.zendesk.com/api/v2/tickets/$ticketID.json"
$ticket = Invoke-RestMethod -Uri $ticketsURI -Method Get -Headers $headers -ContentType "application/json"
$ticket = $ticket.ticket
return $ticket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment