Reputation: 19
How can I run this powershell script in cmd?
$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
Upvotes: 0
Views: 150
Reputation: 126712
Make sure CMD is elevated. You could use WMIC directly from CMD:
wmic nic where "NetConnectionID like '%wireless%'" call disable
Upvotes: 2
Reputation: 127543
you can pass commands to the powershell executeable via the -Command
switch and prefixing the script block with &
.
powershell -Command "& { $adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}; $adaptor.Disable() }"
You can read more by running the command powershell -?
Upvotes: 1