Powershell:在 Windows 10 中获取 GPS 坐标 - 使用 Windows 位置 API?

     2023-02-19     288

关键词:

【中文标题】Powershell:在 Windows 10 中获取 GPS 坐标 - 使用 Windows 位置 API?【英文标题】:Powershell: Getting GPS Coordinates in Windows 10 - Using Windows Location API? 【发布时间】:2018-02-27 11:49:07 【问题描述】:

我正在寻找一种使用 Windows 定位 API 从 powershell 脚本收集内部 GPS 数据的方法,因为 Windows 定位平台不再能够满足需求。以前,有一个 com 对象可供使用。

有没有办法在 Windows 10 中实现这一点?

【问题讨论】:

更多解决方案here. 【参考方案1】:

一个使用System.Device.Location方法的例子,这应该是你要找的。​​p>

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.

【讨论】:

【参考方案2】:

确保已设置位置。否则它会输出“拒绝访问位置信息”

【讨论】:

正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center。

win10怎样打开powershell

win10打开PowerShell方法如下:1、点击开始菜单按钮,并选择所有应用2、找到“windows系统”文件夹,点击里面的PowerShell应用,然后弹出PowerShell命令框。参考技术A在windows10中会经常用到PowerShell,怎么打开呢方法11、点击开始菜单按... 查看详情

win10怎样打开powershell

...并选择所有应用找到“windows系统”文件夹,点击里面的PowerShell应用,然后弹出PowerShell命令框方法二:打开运行框(windows键+R)输入命令powershell方法三:在左下角的搜索框中输入powershell在搜索出来的列表中选择powershell参考技术... 查看详情

删除 over powershell windows 10 Apps

】删除overpowershellwindows10Apps【英文标题】:Removeoverpowershellwindows10Apps【发布时间】:2021-03-3003:37:45【问题描述】:我构建了一个脚本来删除每个Python的Windows10应用程序。我将要删除的应用程序保存在字符串数组中,并将完整的命... 查看详情

PhpStorm、Windows 10 PowerShell 和 Git 命令

】PhpStorm、Windows10PowerShell和Git命令【英文标题】:PhpStorm,Windows10PowerShellandGitcommands【发布时间】:2020-01-0116:19:52【问题描述】:我在Windows上使用PhpStorm,并且正在尝试学习使用CLI。所以在程序设置中,我使用WindowsPowerShell作为本... 查看详情

win10怎样打开powershell

...并选择所有应用找到“windows系统”文件夹,点击里面的PowerShell应用,然后弹出PowerShell命令框方法二:打开运行框(windows键+R)输入命令powershell方法三:在左下角的搜索框中输入powershell在搜索出来的列表中选择powershell参考技术... 查看详情

在 Windows 10 C# 中更改 PC 名称

...问题描述】:我发现命令Rename-Computer-NewName"NewName"当我从Powershell运行它时工作。但是,当我像这样从C#代码运行它时:PowerShellps=PowerShell.Create();ps.AddCommand("Rename-Comput 查看详情

powershell在windows10上安装/启用iis(代码片段)

查看详情

在 powershell ssh 会话中访问 Windows 网络驱动器

】在powershellssh会话中访问Windows网络驱动器【英文标题】:AccessWindowsnetworkdrivesinsidepowershellsshsession【发布时间】:2021-01-1923:35:10【问题描述】:我正在尝试从linux机器远程自动执行Windows上的一些脚本。该脚本将读取共享驱动器上... 查看详情

如何查看 Windows Server 2016 中所有 PowerShell 会话的命令历史记录?

】如何查看WindowsServer2016中所有PowerShell会话的命令历史记录?【英文标题】:HowcanIseethecommandhistoryacrossallPowerShellsessionsinWindowsServer2016?【发布时间】:2017-10-2114:10:27【问题描述】:在哪里可以查看WindowsServer2016中所有会话的完整... 查看详情

powershell测试$filename是否为有效文件名。回答问题“如何在windows10中检查$filename是否是完全有效的文件名?”(代码片段)

查看详情

如何使用 PowerShell 在系统重新启动后延迟 10 分钟在 Windows 任务计划程序中安排任务?

】如何使用PowerShell在系统重新启动后延迟10分钟在Windows任务计划程序中安排任务?【英文标题】:HowtoscheduleataskinWindowsTaskSchedulerwithdelayof10minutesaftersystemrestartedusingPowerShell?【发布时间】:2022-01-1715:07:43【问题描述】:我想在Windo... 查看详情

我如何在 Windows 中使用 cmd/powershell 卸载受密码保护的应用程序 [关闭]

】我如何在Windows中使用cmd/powershell卸载受密码保护的应用程序[关闭]【英文标题】:HowcaniUninstallPasswordProtectedApplicationusingcmd/powershellinwindows[closed]【发布时间】:2021-10-1617:41:51【问题描述】:我只想用那个powershellcmd添加(卸载密... 查看详情

如何通过powershell访问windows 10中的mdb文件?

】如何通过powershell访问windows10中的mdb文件?【英文标题】:Howtoaccessmdbfileinwindows10bypowershell?【发布时间】:2019-04-1109:21:37【问题描述】:按照以下链接中显示的建议,我创建了一个powershell脚本来访问mdb文件。https://devblogs.microsof... 查看详情

如何在 Windows 10 上使用 Powershell 将 Google Colab 与本地 TensorFlow Jupyter 服务器一起使用?

】如何在Windows10上使用Powershell将GoogleColab与本地TensorFlowJupyter服务器一起使用?【英文标题】:HowtouseGoogleColabwithalocalTensorFlowJupyterserverusingPowershellonWindows10?【发布时间】:2020-07-1609:08:10【问题描述】:我正在尝试使用Docker在Window... 查看详情

powershell inline 在竹子中失败,但从 windows powershell CLI 传递

】powershellinline在竹子中失败,但从windowspowershellCLI传递【英文标题】:powershellinlinefailsinbamboobutpassesfromwindowspowershellCLI【发布时间】:2018-02-1617:03:58【问题描述】:我有一个命令将文件从竹复制到Windows机器。我正在使用竹子的pow... 查看详情

PowerShell 脚本不会作为 Windows 计划任务执行

】PowerShell脚本不会作为Windows计划任务执行【英文标题】:PowerShellscriptwon\'texecuteasaWindowsscheduledtask【发布时间】:2012-10-1211:42:37【问题描述】:我有一个PowerShell脚本(有效)。在Windows任务计划程序中,我创建了一个新任务来执... 查看详情

运行PowerShell进程时如何阻止Windows 10机器休眠/休眠?

】运行PowerShell进程时如何阻止Windows10机器休眠/休眠?【英文标题】:Howtostopawindows10machinefromsleeping/hibernatingdownwhenrunningapowershellprocess?【发布时间】:2021-03-1706:52:05【问题描述】:我有一个powershell进程,它从远程服务器读取记录... 查看详情

如何使用 Powershell 更改 Windows 10 中的电源计划并在长脚本后恢复为原始设置?

】如何使用Powershell更改Windows10中的电源计划并在长脚本后恢复为原始设置?【英文标题】:HowtochangePowerPlaninWindows10withPowershellandrevertafterlongscripttooriginalsettings?【发布时间】:2020-04-0816:27:17【问题描述】:如何制作一个PowerShell脚... 查看详情