Skip to content

Instantly share code, notes, and snippets.

@mikebridge
Last active January 27, 2021 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikebridge/b77dc6c14c47d5d717bc3655bb46f397 to your computer and use it in GitHub Desktop.
Save mikebridge/b77dc6c14c47d5d717bc3655bb46f397 to your computer and use it in GitHub Desktop.
Get the running ngrok host name via PowerShell
function Get-NGrokHostName
{
Param(
[Parameter(Mandatory = $True)][String]$TunnelName
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$response = Invoke-WebRequest 'http://127.0.0.1:4040/api/tunnels'
$obj = $response.Content | ConvertFrom-Json
$url = $obj.tunnels |
Where-Object { $_.name -eq $TunnelName } |
Select-Object -First 1 |
Select-Object -ExpandProperty "public_url"
return $url
}
Export-ModuleMember -Function Get-NGrokHostName
@mikebridge
Copy link
Author

Powershell version of this:

curl --silent http://127.0.0.1:4040/api/tunnels | jq -r '.tunnels[] | select(.name == "MY_TUNNEL_NAME") | .public_url'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment