Freshdesk StatusBoard Powershell Scripts - #1 Get Ticket Summary
Freshdesk Powershell Scripts - Get ticket summary
Mission get to the current open ticket count into an include file for our board
- Run this Powershell script as a Scheduled Task every 15-minutes
- Updates a text file with the current open ticket count from Freshdesk
- Later we'll pick this file up our our statusboard
This is what we're aiming for on our operations monitor
- Tickets heading up or down using indicator
- Open tickets differentiated from all tickets
- Freshdesk Ticket count by Engineer / Agent
- Tickets heading up or down using indicator
- Open tickets differentiated from all tickets
- Freshdesk Ticket count by Engineer / Agent
# Part one script starts here
# API Key
$FDApiKey="Enter your API Key Here"
#################################################
# Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
# Prep
$pair = "$($FDApiKey):$($FDApiKey)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$FDHeaders = @{ Authorization = $basicAuthValue }
##################################################
# The Doing part
$FDBaseEndpointSummary = "https://ChangeToYourURL.freshdesk.com/helpdesk/tickets/summary.xml?view_name=open"
$FDContactData = Invoke-WebRequest -uri $FDBaseEndpointSummary -Headers $FDHeaders -Method GET -ContentType application/json
# The Dispay part
$FDOutput = $FDContactData -replace ".*integer" -replace "</view.*" -replace ".*?>" -replace "</count.*"
$FDOutput = $FDOutput.Trim()
# Update the include file and change to ASCII
$FDOutput | Out-File d:\EnterYourFilepath\callCount.inc -Encoding ASCII
# Script ends
Thanks for the big help! Been stuck trying to get into various APIs for a while through PowerShell and as it turns out I've been running into the TLS1.0 issue. That one line has already made life a whole lot easier! :)
ReplyDeleteIt says The remote server returned an error: (404) Not found
ReplyDeleteDude! You are awesome, cheers for this, My GET requests now work. now all I have to do is work out how to POST, hehe.
ReplyDeleteIs part two coming anytime soon?
ReplyDeleteYep coming soon with the web page part
DeleteGiving this a try now... looking fwd to seeing more on this
Delete