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
CountryCode : US
CountryName : United States
RegionCode : FL
RegionName : Florida
City : Tampa
ZipCode : 33626
Latitude : 28.0898
Longitude : -82.576
MetroCode : 539
AreaCode : 813
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 10 years ago