0

如何在 cmd 中运行这个 powershell 脚本?

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
4

2 回答 2

2

确保 CMD 升高。您可以直接从 CMD 使用 WMIC:

wmic nic where "NetConnectionID like '%wireless%'" call disable
于 2013-09-13T19:49:38.127 回答
1

您可以通过-Command开关将命令传递给可执行的 powershell,并在脚本块前加上&.

powershell -Command "& { $adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}; $adaptor.Disable() }"

您可以通过运行命令阅读更多内容powershell -?

于 2013-09-13T19:00:25.350 回答