Powershell:在 Windows 10 中获取 GPS 坐标 - 使用 Windows 位置 API? [英] Powershell: Getting GPS Coordinates in Windows 10 - Using Windows Location API?
本文介绍了Powershell:在 Windows 10 中获取 GPS 坐标 - 使用 Windows 位置 API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种使用 Windows 定位 API 从 powershell 脚本收集内部 GPS 数据的方法,因为 Windows 定位平台不再能够满足需求.以前,有一个 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
方法的例子,这应该是你要找的.p>
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屋!
查看全文