Today I’m going to share with you how to find your public IP address using Powershell. There might be a time where you might need to sort through multiple public addresses and want to be able to find the WHOIS information rather quickly. To do that, we will use the site https://ipinfo.io/ and calling their API to use with Powershell. Here’s how you do it.
Find Public IP Address Using Powershell
PS C:\> Invoke-RestMethod -Uri https://ipinfo.io ip : redacted hostname : redacted city : redacted region : California country : US loc : redacted postal : redacted org : redacted PS C:\> Invoke-RestMethod -Uri https://ipinfo.io/8.8.8.8 ip : 8.8.8.8 hostname : google-public-dns-a.google.com city : Mountain View region : California country : US loc : 37.3860,-122.0840 postal : 94035 phone : 650 org : AS15169 Google LLC
So I’m not all for showing you my exact location however, I am all for showing you what Google’s public DNS server are. If you omit an IP address, by default it will show your information. However, if you append an IP address at the end it should give you the details regarding that IP.