0
我正在尋找一種方法來使用Windows位置API從PowerShell腳本收集內部GPS數據,因爲Windows位置平臺不再能夠滿足需求。以前,有一個com對象可以使用。Powershell:在Windows 10中獲取GPS座標 - 使用Windows位置API?
有沒有辦法在Windows 10中完成這項工作?
我正在尋找一種方法來使用Windows位置API從PowerShell腳本收集內部GPS數據,因爲Windows位置平臺不再能夠滿足需求。以前,有一個com對象可以使用。Powershell:在Windows 10中獲取GPS座標 - 使用Windows位置API?
有沒有辦法在Windows 10中完成這項工作?
使用System.Device.Location
方法的一個例子,這應該是你正在尋找的。
Add-Type -AssemblyName System.Device #Required to access System.Device.Location namespace
$GeoWatcher = New-Object System.Device.Location.GeoCoordinateWatcher #Create the required object
$GeoWatcher.Start() #Begin resolving current locaton
while (($GeoWatcher.Status -ne 'Ready') -and ($GeoWatcher.Permission -ne 'Denied')) {
Start-Sleep -Milliseconds 100 #Wait for discovery.
}
if ($GeoWatcher.Permission -eq 'Denied'){
Write-Error 'Access Denied for Location Information'
} else {
$GeoWatcher.Position.Location | Select Latitude,Longitude #Select the relevent results.
}