windows - 如何使用 PowerShell 查找不同语言的 wifi 适配器
问题描述
powershell 脚本应该启用/禁用无线网络适配器。所以我使用了 NetAdaper cmdlet。
Get-NetAdapter
Enable-NetAdapter -Name 'Wi-Fi'-Confirm:$false
Disable-NetAdapter -Name 'Wi-Fi'-Confirm:$false
它在英语语言系统上运行良好。在配置了其他语言的系统上,由于无线适配器没有“Wi-Fi”作为名称,它会失败。
例如德语。
Enable-NetAdapter -Name 'WLAN'-Confirm:$false
Disable-NetAdapter -Name 'WLAN'-Confirm:$false
如何归档在所有语言上运行的这个脚本?
解决方案
Get-NetAdapter
有一个名为的字段InterfaceType
,其中包含基于此枚举的值:
根据该文档, type71
是一个Wireless80211
设备。
只是为了表明它在那里:
[int][System.Net.NetworkInformation.NetworkInterfaceType]::Wireless80211
所以你可以做这样的事情:
Get-NetAdapter | Where-Object InterfaceType -eq 71
这将返回所有无线适配器的列表。
推荐阅读
- reactjs - 如何为第三方网站创建可嵌入的 next.js (react) 组件?
- javascript - 如何在javascript中添加和删除元素行
- css - Chrome 工作区:元素中的更改>样式未保存到源选项卡
- firebase - 谷歌分析访问旧数据
- angular - 角度材料:更改选项组的背景颜色不起作用
- sql - Amazon Redshift 使用 COPY 命令仅从 JSON 中获取 1 行
- node.js - 一些 axios.get 请求失败并显示“请求失败,状态码 404”
- amazon-web-services - 如何加密并安全存储和传输 SSH 的私钥
- dojo - IBM Navigator:ecm/widget/listView/ContentList 带复选框
- json - 根据子对象中是否存在条目进行过滤