Automate Freshdesk Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Freshdesk data from PowerShell? This article demonstrates how to utilize the Freshdesk Cmdlets for tasks like connecting to Freshdesk data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Freshdesk is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Freshdesk.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Freshdesk; this tutorial shows how to use the Provider to create, retrieve, update, and delete Freshdesk data.

Once you have acquired the necessary connection properties, accessing Freshdesk data in PowerShell can be enabled in three steps.

FreshDesk makes use of basic authentication. To connect to data, set the following connection properties:

  • Domain: Set this to the domain associated with your FreshDesk account. For example, in your URL: https://my_domain.freshdesk.com.
  • APIKey: Set this to the API key associated with your FreshDesk account. To retrieve your API key, Log into your support Portal -> Click on profile picture in the top right corner -> profile settings page. The API key will be available below the change password section to the right.
  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Freshdesk\lib\System.Data.CData.FreshDesk.dll")
  2. Connect to Freshdesk:

    $conn= New-Object System.Data.CData.FreshDesk.FreshDeskConnection("Domain=MyDomain;APIKey=myAPIKey;")
    $conn.Open()
  3. Instantiate the FreshDeskDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Name from Tickets"
    
    $da= New-Object System.Data.CData.FreshDesk.FreshDeskDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.id $_.name
    }

Update Freshdesk Data

$cmd =  New-Object System.Data.CData.FreshDesk.FreshDeskCommand("UPDATE Tickets SET Status='2' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.FreshDesk.FreshDeskParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Freshdesk Data

$cmd =  New-Object System.Data.CData.FreshDesk.FreshDeskCommand("INSERT INTO Tickets (Status) VALUES (@myStatus)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.FreshDesk.FreshDeskParameter("@myStatus","2")))
$cmd.ExecuteNonQuery()

Delete Freshdesk Data

$cmd =  New-Object System.Data.CData.FreshDesk.FreshDeskCommand("DELETE FROM Tickets WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.FreshDesk.FreshDeskParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Freshdesk Data Provider to get started:

 Download Now

Learn more:

Freshdesk Icon Freshdesk ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Freshdesk data including Agents, Companies, Contacts, Groups, and more!