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

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

#requires -Version 3.0
$ip = Invoke-RestMethod -Uri 
Invoke-RestMethod -Uri "$IP" |
  Select-Object -ExpandProperty Country

Twitter This Tip! ReTweet this Tip!