我们正在使用专用网络,其中端口被防火墙阻止。
我们将提出为我们的机器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/