如何使用PowerShell查找不同语言的wifi适配器

问题描述 投票:0回答:1

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

如何存档这个在所有语言上运行的脚本?

windows powershell wifi
1个回答
0
投票

Get-NetAdapter
有一个名为
InterfaceType
的字段,其中包含基于此枚举的值:

https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.networkinterfacetype?view=net-5.0

根据该文档,类型

71
是一个
Wireless80211
设备。

只是为了表明它在那里:

[int][System.Net.NetworkInformation.NetworkInterfaceType]::Wireless80211

所以你可以这样做:

Get-NetAdapter | Where-Object InterfaceType -eq 71

这将返回所有无线适配器的列表。

© www.soinside.com 2019 - 2024. All rights reserved.