Get IP Address Geolocation

by Apr 23, 2015

Would you like to know where a public IP address is located? Provided you have Internet access, you can query one of the public information services.

This example gets you the geolocation of an IP address. Make sure you replace the sample IP address with your own publicly exposed IP address. Go to websites like to find out your IP address. If you use a private IP address, the web service cannot report back any geo location data obviously.

#requires -Version 3

$ipaddress = ''
$infoService = "$ipaddress"

$geoip = Invoke-RestMethod -Method Get -URI $infoService


Twitter This Tip! ReTweet this Tip!