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
的字段,其中包含基于此枚举的值:
根据该文档,类型
71
是一个 Wireless80211
设备。
只是为了表明它在那里:
[int][System.Net.NetworkInformation.NetworkInterfaceType]::Wireless80211
所以你可以这样做:
Get-NetAdapter | Where-Object InterfaceType -eq 71
这将返回所有无线适配器的列表。