Answer
That’s right, to find out your external IP address, you can use any online service. You can get data from an external web page from PowerShell using the Invoke-WebRequest cmdlet (an example of parsing and scraping a web pages using Invoke-WebRequest).
You can parse the page of any of the popular sites to check the external IP address, but it is easier to use any of the services that contain only the ip address (in the form of plain-text).
You can use the following sites:
- http://ipinfo.io/ip
- http://ifconfig.me/ip
- http://icanhazip.com
- http://ident.me
- http://smart-ip.net/myip
For example, to find out your current external IP address, from which you access the Internet, open the PowerShell console and run the command:
(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
As you can see, the command successfully returned to the PoSh console the external IP address from which the connection came.
Or even you can get your GeoIP data (such a country, city, region, and GPS coordinates).
Invoke-RestMethod -Uri ('http://ipinfo.io/'+(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
You should understand that in most cases the resulting IP will not be the real static “white” IP of your computer. In most cases, this will be either the external IP address of the router (when NAT is used), the dynamic IP address issued by provider or the proxy server address.