Powershell:在Windows 10中获取GPS坐标-使用Windows位置API? [英] Powershell: Getting GPS Coordinates in Windows 10 - Using Windows Location API?
本文介绍了Powershell:在Windows 10中获取GPS坐标-使用Windows位置API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种使用Windows Location API从Powershell脚本收集内部GPS数据的方法,因为Windows Location Platform不再能够满足需求.以前,有一个com对象要使用.
I'm looking for a way to gather internal GPS data from a powershell script using Windows Location API, as the Windows Location Platform is no longer able to satisfy the need. Previously, there was a com object to use.
在Windows 10中有没有办法做到这一点?
Is there a way for this to be accomplished in Windows 10?
推荐答案
使用System.Device.Location
方法的示例,这应该是您想要的.
An example of using the System.Device.Location
method, this should be what you're looking for.
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.
}
这篇关于Powershell:在Windows 10中获取GPS坐标-使用Windows位置API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文