Hi, admin! In considered one of my PowerShell scripts, I wanted to decide the present exterior IP tackle of the Windows pc from the command line or (greatest) with some easy PowerShell perform. There are fairly just a few web pages the place you’ll find out your public IP tackle, however I don’t perceive how to entry them from my PoSh script and return the information from the net web page.
That’s proper, to discover out your exterior IP tackle, you should use any on-line service. You can get knowledge from an exterior internet web page from PowerShell utilizing the Invoke-WebRequest cmdlet (an instance of ).
You can parse the web page of any of the favored websites to test the exterior IP tackle, however it’s simpler to use any of the providers that comprise solely the ip tackle (within the type of plain-text).
You can use the next websites:
For instance, to discover out your present exterior IP tackle, from which you entry the Internet, open the PowerShell console and run the command:
(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
As you may see, the command efficiently returned to the PoSh console the exterior IP tackle from which the connection got here.
Or even you will get your GeoIP knowledge (such a rustic, metropolis, area, and GPS coordinates).
Invoke-RestMethod -Uri ('http://ipinfo.io/'+(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
You ought to perceive that normally the ensuing IP won’t be the true static “white” IP of your pc. In most instances, this can be both the exterior IP tackle of the router (when NAT is used), the dynamic IP tackle issued by supplier or the proxy server tackle.