Windows Powershell One Liner | Get External IP Address

Reading Time: 2 minutes

Windows Powershell One Liner script: Get External IP

This one is pretty straight forward. If you ever need to check your external IP address for informational purposes or want to verify an address change after connecting to a VPN connection, this simple windows powershell script should satisfy your needs. It displays your current external IP address.

The Code

windows powershell one liner

Download this windows powershell script on github


How it works

First we use the Invoke-RestMethod cmdlet, which sends an HTTP or HTTPS request to a RESTful web service. We then enter the url which is a website that returns various information about your External IP like hostname, city, country, location by latitude, longitude, and many other options. We then pipe the command to select only the ip, and thats pretty much it.

Interested in learning powershell?

Check out “Mastering Windows PowerShell Scripting – Second Edition: One-stop guide to automating administrative tasks“. This comprehensive guide starts from scratch and covers advanced-level topics to make you a PowerShell expert. The first module, PowerShell Fundamentals, begins with new features, installing PowerShell on Linux, working with parameters and objects, and also how you can work with .NET classes from within PowerShell.


We would also like to give a shout-out to Anuj over at Feedspot. Anuj was able to help us get listed on Feedspot’s “Top 50 Programming Blog”. If you don’t know what Feedspot is, it is a website where you can read your favorite Blogs, News websites, RSS Feeds, Youtube Channels and Social sites accounts from one place.

This post is located under the Programming Category

Enjoyed this post? Check out “How to create a windows password reset tool in powershell



Leave a Reply

Your email address will not be published.