Finding Public IP Address

by Oct 5, 2016

Would you like to know what your public IP address is that you are currently using while being connected to the Internet? It’s a one-liner:

#requires -Version 3.0
Invoke-RestMethod -Uri http://checkip.amazonaws.com/

With this IP address, you can ask the Internet where you are geographically located, too:

#requires -Version 3.0
$ip = Invoke-RestMethod -Uri http://checkip.amazonaws.com/ 
Invoke-RestMethod -Uri "http://geoip.nekudo.com/api/$IP" |
  Select-Object -ExpandProperty Country

Twitter This Tip! ReTweet this Tip!