Freshdesk Powershell find UserID by email address

How to UserID by email address in Freshdesk with PowerShell


1. Prep for testing 

Update this url with yourdomain to locate a suitable user account and email address. https://yourdomain.freshdesk.com/api/v2/contacts
The output is in .json format but readable enough.

2. The PowerShell 


#################################################
# 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

Comments

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