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
  2. It says The remote server returned an error: (404) Not found

    ReplyDelete
  3. Dude! You are awesome, cheers for this, My GET requests now work. now all I have to do is work out how to POST, hehe.

    ReplyDelete
  4. Is part two coming anytime soon?

    ReplyDelete
    Replies
    1. Yep coming soon with the web page part

      Delete
    2. Giving this a try now... looking fwd to seeing more on this

      Delete

Post a Comment

Popular posts from this blog

Server Manager Refresh completed with one or more warning

Hyper-V could not replicate changes for virtual machine as replication is suspended on the Replica server

Shrewsoft VPN client - can't open Access Manager