REST API version of https://ip.zscaler.com/ to test connections status (or command line connection test?)

Is there a programmatic way to verify that the client is connected to Zscaler?

Rather than hack together a script that parses strings from this, is there a purpose-built API version?

Invoke-RestMethod https://ip.zscaler.com/

Hi Hugh -

I always use the following - it’ll return “OK” or status 200 if oyu are conencted to Zscaler -

Invoke-RestMethod http://gateway.zscloud.net/vpntest

Update with your Zscaler cloud of choice. This works via our GRE / ipsec tunnels - haven’t tested other options!

1 Like

Here’s a little Powershell script I threw together to get this data and then I can push it into a CSV or Excel spreadsheet

#Get the raw data
$rawData = Invoke-WebRequest -Uri http://ip.zscaler.com

#Parse the raw data
$proxy = ($rawData.ParsedHTML.documentElement.outerText.Split("`n").Trim() -Match ("Zscaler hostname")).Split(' ')[-1]
$dataCenter = (($rawData.ParsedHTML.documentElement.outerText.Split("`n").Trim() -Match ("Zscaler Cloud:")).Split(':'))[-1].Split(' ')[1]
$gateway = ($rawData.ParsedHTML.documentElement.outerText.Split("`n").Trim() -Match ("Gateway IP")).Split(' ')[-1]
$proxyIP = ($rawData.ParsedHTML.documentElement.outerText.Split("`n").Trim() -Match ("proxy virtual IP")).Split(' ')[-1]
$publicIP = ($rawData.ParsedHTML.documentElement.outerText.Split("`n").Trim() -Match ("Your request is arriving")).Split(' ')[-1]

#Remove trailing punctuation
$proxyIP = $proxyIP.Substring(0,$proxyIP.Length-1)
$proxy = $proxy.Substring(0,$proxy.Length-1)

[PSCustomObject]@{
    Proxy = $proxy
    DataCenter = $dataCenter
    Gateway = $gateway
    MyProxyIP = $proxyIP
    MyPublicIP = $publicIP
    Timestamp = Get-Date
}
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.