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 



# 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

Part Two coming soon 

Follow by Email on right hand side to get the next instalment

Post Feedback below to help others


Comments

  1. 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! :)

    ReplyDelete

Post a Comment

Popular posts from this blog

Server Manager Refresh completed with one or more warning

Event ID 122 Access to Drivers on Windows Update Blocked by Policy - Fix Here

Hyper-V failed to enable replication on the Replica server for the Virtual Machine