When I start an ngrok client with ./ngrok tcp 22 it runs in the foreground and I can see the randoming generated forwarding URL, such as tcp://0.tcp.ngrok.io:
./ngrok tcp 22
tcp://0.tcp.ngrok.io:
If you love PowerShell, here it is in variables.
$ngrokOutput = ConvertFrom-Json (Invoke-WebRequest -Uri http://localhost:4040/api/tunnels).Content $httpsUrl = $ngrokOutput.tunnels.public_url[0] $httpUrl = $ngrokOutput.tunnels.public_url[1]