I am using PowerShell to have a script on Windows 10 that reports back some position information. The laptops have GPS receivers built into them, when using software to query GPS information via a comm port, the position information is highly accurate, within a few meters. When I use the Location API via PowerShell, the location reported is usually within 300 meters at best, 30K+ meters at worst.
Here is a sample of the code I'm using:
# Time to see if we can get some location information
# Required to access System.Device.Location namespace
Add-Type -AssemblyName System.Device
# Create the required object
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher
# Begin resolving current locaton
while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied'))
#Wait for discovery
Start-Sleep -Seconds 15
The original code sample I found on the internet had the discovery pause for 100 milliseconds, I've tried going as high as 45 seconds with no change in accuracy. I get the position via this method:
#Select the relevent results.
$LocationArray = $GeoWatcher.Position.Location
After reviewing the documentation for System.Device.Location, I did try using:
For a desired accuracy of "high" but the results appear to be roughly the same. I did confirm my request for higher accuracy data is being processed:
DesiredAccuracy : High
MovementThreshold : 0
Permission : Granted
Is there a way for me to get GPS information via the Location API that is as accurate as when I query the GPS comm port?