powershell - 如何确保使用Powershell启用或禁用Wi-Fi?

标签 powershell wifi powershell-2.0

我们正在使用专用网络,其中端口被防火墙阻止。

我们将提出为我们的机器IP地址打开端口的请求。

如果启用了wi-fi,则系统将具有2个IP地址,并且如果我们的连接通过该IP地址进行路由,则我们将无法访问专用网络内部的计算机。

我想知道Powershell中是否有任何方法可以确保状态(是否启用/禁用了wi-fi)。

最佳答案

这一个类轮列出了与无线或wifi匹配且已启用的所有网络适配器。

get-wmiobject -class win32_networkadapter -namespace root\CIMV2 | where-object {$_.Name -match "Wifi" -or $_.Name -match "wireless" -and $_.name -notmatch "Microsoft Virtual WiFi Miniport Adapter" -and $_.netenabled -eq $true}   | select description, netenabled

此禁用:
get-wmiobject -class win32_networkadapter -namespace root\CIMV2 | where-object {$_.Name -match "Wifi" -or $_.Name -match "wireless" -and $_.name -notmatch "Microsoft Virtual WiFi Miniport Adapter" -and $_.netenabled -eq $true } | % { $_.disable() }

此启用:
get-wmiobject -class win32_networkadapter -namespace root\CIMV2 | where-object {$_.Name -match "Wifi" -or $_.Name -match "wireless" -and $_.name -notmatch "Microsoft Virtual WiFi Miniport Adapter" -and $_.netenabled -eq $false } | % { $_.enable() }

关于powershell - 如何确保使用Powershell启用或禁用Wi-Fi?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10204140/

相关文章:

powershell - 如何获取用户所属的所有组?

powershell - 为什么我在 PowerShell sort -unique Count 中得到此输出

Powershell交换模块远程邮箱问题

powershell - Powershell中批处理文件中的错误识别

android - 是否可以通过 iOS/Android 上的应用程序控制 WiFi/热点/BT 功能

Azure Runbook 命令

powershell - 将自定义元数据添加到 Azure 虚拟机

iPhone 电池续航时间建议

crash - 如何使用 [[UIApplication sharedApplication] valueForKey : @"statusBar"] on ios13? 获取 wifi 信号强度

powershell - 这是 PowerShell 类型解析机制中的边缘案例吗?