/build/static/layout/Breadcrumb_cap_w.png

Getting approximate location of Windows Computers via IP address

When working with Windows 8 Tablets, like the Venue 11 Pro, geolocation can be difficult.  I developed a script to determine how to get an approximate location into the K1000 as a custom inventory field.

First create a PowerShell script called location.ps1

================== Contents of Location.ps1  ============================
$MyPublicIP = (Invoke-WebRequest 'http://myip.dnsomatic.com' -UseBasicParsing).Content
$html = Invoke-WebRequest -Uri "http://freegeoip.net/xml/$myPublicIP" -UseBasicParsing 
$content = [xml]$html.Content
$content.response  | Out-File C:\Temp\location.txt
====================================================================

This will dump location data into C:\Temp in a file called location.txt

Next we need to create a custom inventory field to capture that data.  I called mine Location and used the following Custom Inventory Rule:

ShellCommandTextReturn(type C:\temp\location.txt)

Lastly, create a script to run the PowerShell command and gather the inventory.  Upload the location.ps1 as a dependency of the script.

In a task add an action that will run a batch file with the following contents:

powershell.exe -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file "location.ps1"

Add another action after that action that launches a program which starts in the $(KACE_INSTALL) directory and launches kdeploy.exe with the paramters -custominventory

Run this script on your machines and the custom inventory will look something like this:

Ip : 155.233.4.67
CountryCode : US
CountryName : United States
RegionCode : FL
RegionName : Florida
City : Tampa
ZipCode : 33626
Latitude : 28.0898
Longitude : -82.576
MetroCode : 539
AreaCode : 813


Comments

  • That is really impressive. Now that you have that information what do you do with it? I am curious about the business case. - Jbr32 9 years ago
    • Windows 8 tablets are kind of hybrid devices. Since it is a full desktop OS, we manage it with the K1000. But it is still a very mobile device and we will need to find out where that device is in case it is lost or stolen. We have our EMM solution that can pinpoint locations of iOS and Android devices but since Windows 8 tablets are becoming more popular we need to be able to somehow locate those devices.

      I am hoping to do a couple of things. First i would like to be able to take that data, parse it and create a custom inventory field with a hyperlink to the coordinates.

      If i can find a way to get more accurate coordinates i would like to be able to pinpoint a more exact location. That will be the ultimate goal. For now it is just s simple way to see coordinates on a Windows 8 device. - jamie_kace 9 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ