Powershell API Code Examples

The API v2 Reference documentation contains code samples for multiple languages. Please add PowerShell code samples as well so that the API can be used with native Windows tools


4 people have this question

Using Powershell to pull open ticket information and display as a dashboard page - notes here: 

https://zoomcloud.blogspot.co.nz/2016/12/freshdesk-statusboard-powershell.html


Mark

Thanks Mark! I was able to get it to output the number of open tickets using your script, so I'll see if I can modify it to delete users, which is what prompted my initial request

Mark, any suggestions on how to get a contact's user ID provided I can supply the email address? I was able to modify the script you provided and get it to delete a user if I manually look up the user ID from the web interface and enter it, but I can't seem to figure out any way to first get the ID in any automated fashion in order to pass it to the delete portion of the script

Hi Travis


Try the code below (not sure how this will post) 

Use this url to confirm a live user email and ID to compare to the script output. https://yourdomain.freshdesk.com/api/v2/contacts 

Added a blog post with the script in case it does not post https://zoomcloud.blogspot.co.nz/2016/12/freshdesk-powershell-find-userid-by.html


#################################################

# Freshdesk Find Contact by email

#################################################

 

 

# Find this user

$userEmail = "someone@somewhere.com"

 

 

# Enter FreshDesk Domain

$myDomain = "domainname"

 

 

# API Key

$FDApiKey="myapikey"

 

 

#################################################

 

# Prep

$pair = "$($FDApiKey):$($FDApiKey)"

$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)

$base64 = [System.Convert]::ToBase64String($bytes)

$basicAuthValue = "Basic $base64"

$FDHeaders = @{ Authorization = $basicAuthValue }

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12

 

 

# The Doing part

$FDBaseEndpointSummary = "https://$myDomain.freshdesk.com/api/v2/contacts?email=$userEmail"

 

$FDContactData = Invoke-WebRequest -uri $FDBaseEndpointSummary -Headers $FDHeaders -Method GET -ContentType application/json | ConvertFrom-Json

 

# The Dispay part

$Output = $FDContactData | Select id

 

$Output 

Login or Signup to post a comment