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 Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, and holds a number of certifications, including those relating to SQL Server, Linux, SharePoint and network security. 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?

      merci!

  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 *

*