locked
Getting GPS coordinates with powershell? RRS feed

  • Question

  • Most laptops these days have a GPS in them. Is there a way to access the internal GPS with powershell?

    What i am interested in is accessing the current GPS coordinates.

    <strike>What i have seemed to find is that there isnt any windows function for this and that it is quite a fragmented market? Although applications like google chrome can consistently get the gps coordinates regardless of manufacturer. So how do they do it? Can it be done in powershell as well, and if so how?</strike>

    <strike>Or is there a good commandline application which i can use with powershell that supports getting coordinates from diffrent manufacturers GPS systems? This is primarly about HP's Laptops, although i would like it working for some Dell Laptops aswell.</strike>

    I found Windows location platform http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinate.aspx How can i access this .net class in powershell?
    • Edited by Plindgren Monday, October 14, 2013 8:16 AM
    Monday, October 14, 2013 7:44 AM

Answers

  • Try this:

    $location=new-object -ComObject LocationDisp.DispLatLongReport
    $location


    ¯\_(ツ)_/¯

    • Marked as answer by Plindgren Monday, October 14, 2013 9:14 AM
    Monday, October 14, 2013 8:21 AM

All replies

  • Try this:

    $location=new-object -ComObject LocationDisp.DispLatLongReport
    $location


    ¯\_(ツ)_/¯

    • Marked as answer by Plindgren Monday, October 14, 2013 9:14 AM
    Monday, October 14, 2013 8:21 AM
  • Via PowerShell 3.0

    Add-type -AssemblyName System.Device
    $location=New-Object System.Device.Location.GeoCoordinate


    ¯\_(ツ)_/¯

    Monday, October 14, 2013 8:29 AM
  • Both alternatives gives invalid information. Either 0 0  or NaN

    I've tried doing it with and without administrator elevation. What might i be missing? Do you get a correct output from these lines?

    Monday, October 14, 2013 8:49 AM
  • It only works if you have a compatible GPS installed. Most laptops do NOT have a GPS.  A few may have one but it may not be compatible.  Check with the GPS vendor.

    From what I can see - no HP and NO Dell laptops have GPS installed.


    ¯\_(ツ)_/¯

    Monday, October 14, 2013 9:02 AM
  • Hmm. Fooled by bloatware and chrome then i guess, We will have to look into a diffrent solution for this.

    Thank you for the help.

    Monday, October 14, 2013 9:14 AM
  • I just did a quick scan.  I see no laptops or tablets with Windows 8 or RT that come with GPS.  I do not even see it as an option.

    I think you are mixing up the listed "Compass, gyroscope and accelerometer" with a GPS.  Windows surface, some Windows 8 tablets and a very few laptops have those items installed.

    Many Windows 8 phones are "location aware" due to the ability to triangulate on Cell towers.  Every cell tower has a very accurately defined geographic location.  The cell radios are capable of triangulation on the towers and are accurate to within a few meters.  Some Windows 8 phones come with full GPS.  Mine does and works the map very nicely.  It can plot a trip just like the big guys.

    If you purchase and install a GPS that is Windows logo'd it will allow you to read the location with PowerShell.

    You can use either a Garmin USB or Bluetooth device with Windows XP/7/8,  The API will likely only be available on Windows Vista or later.


    ¯\_(ツ)_/¯

    Monday, October 14, 2013 9:32 AM