PowerShell One-Liner: Get External IP Address
Need your External IP address? Just use the following in PowerShell 3 and above
$ip = (Invoke-WebRequest https://ipinfo.io/ip).Content.Trim()
As a bonus, you can also get additional IP information using ipinfo.io's JSON web service.
$jsonip = Invoke-WebRequest https://ipinfo.io/json $ipinfo = Convertfrom-JSON $jsonip.Content $ipinfo.ip $ipinfo.hostname $ipinfo.city $ipinfo.region $ipinfo.country $ipinfo.loc $ipinfo.org