How to Get My Public IP Address Using PowerShell

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:

  • http://smart-ip.web/myip

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 "").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 (''+(Invoke-WebRequest -uri "").Content

Tip. If you entry the Internet via a proxy server, then you may authorize on it from PowerShell utilizing this .

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.

Check Also

Configuring Network Adapter Settings with PowerShell: IP Address, DNS, Default G…

In this text we’ll present you find out how to configure community adapter parameters in …

Leave a Reply

Your email address will not be published. Required fields are marked *