PowerShell One-Liner: Get External IP Address

Need your External IP address? Just use the following in PowerShell 3 and above

As a bonus, you can also get additional IP information using ipinfo.io‘s JSON web service.

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in PowerShell
4 comments on “PowerShell One-Liner: Get External IP Address
  1. Ben says:

    If you want just the IP there’s no need to parse the JSON response, just request http://ipinfo.io/ip instead

    • Chrissy LeMaire says:

      Ha! Even better. Thanks, Ben!

      I saw you are from ipinfo.io. Would it be possible to remove the carriage return (or whatever that is) so that trim() is not needed?


  2. Grey Panther says:

    There is also http://curlmyip.com/ for just a plain, simple IP.

    • Chrissy LeMaire says:

      Cute URL! I was hoping that wouldn’t have extra white space but alas, that one too returns the same thing as ipinfo.

Leave a Reply

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