Powershell Tip #95: Find the Geolocation of an IP Address

By | April 22, 2016

Tip: You can get some informations about an IP Address (Country, City, Code, TimeZone, Latitude, Longitude, etc.)

powershell-ip-address-geolocation-city-county-code-timezone-latitude-longitude


previous-buttonnext-button

3 thoughts on “Powershell Tip #95: Find the Geolocation of an IP Address

  1. Pingback: Powershell Tip #94: Delete files and folder longer than 259 characters | Powershell Guru

  2. Pingback: Powershell Tip #96: Clear all event logs | Powershell Guru

  3. Kirt Carson

    The API was retired. Below is same function with some changes to work with new API.

    Function Get-IPGeolocation
    {
    Param
    (
    [string]$IPAddress
    )

    $request = Invoke-RestMethod -Method Get -Uri “https://ipapi.co/$IPAddress/json”

    [PSCustomObject]@{
    IP = $request.IP
    City = $request.City
    Country = $request.Country_Name
    Code = $request.Country_Code
    Location = $request.Latitude
    Longitude = $request.Longitude
    TimeZone = $request.Timezone
    }
    }

    Reply

Leave a Reply

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