如何在 cmd 中运行这个 powershell 脚本?
$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
如何在 cmd 中运行这个 powershell 脚本?
$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
确保 CMD 升高。您可以直接从 CMD 使用 WMIC:
wmic nic where "NetConnectionID like '%wireless%'" call disable
您可以通过-Command
开关将命令传递给可执行的 powershell,并在脚本块前加上&
.
powershell -Command "& { $adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}; $adaptor.Disable() }"
您可以通过运行命令阅读更多内容powershell -?