Hey, I want to deactivate and then activate my wlan adapter via powershell. I already queried the Hardware-ID of the device. My script looks like this:

$wireless = Get-WmiObject win32_networkadapter | where {$_.DeviceId -eq 12}
$wireless.Disable()
Start-Sleep -s 1
$wireless.Enable()
read-host

But when run the script it throws no error. But the wlan-connection keeps established. I'm pretty shure its the right hardware-ID (i only have one device from intel, and that's my wireless lan device).

I already googled the problem, but couldn't solve it :-/ Happy for any help! Thanks! Tobi

link|improve this question

25% accept rate
feedback

3 Answers

up vote 2 down vote accepted

In some situations like this i recommend don't reinvent the wheel. Windows has for years the command netsh, you could use for this task:

Disable the adapter:

netsh interface set interface "The Name of your Wireless Adapter" Disabled

Enable the adapter:

netsh interface set interface "The Name of your Wireless Adapter" Enable

don't forget to run them as admin

link|improve this answer
I had to enter the line "netsh interface set interface name = "NameOfMyInterface" admin=enable. When no authenticated as an admin, netsh will return that the requested interface doesn't exist insted of an errormessage like "no permission". Tanks for you help! – Tobi Feb 4 '11 at 0:14
feedback

Is one second long enough for it to disable the adaptor? What happens if you skip the enable?

link|improve this answer
feedback

One possible explanation is that the PowerShell scripts does not have Administrator access.

For more info see also Windows Network adaptor disable enable via Powershell.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.