Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 I run the script it throws no error. But the wlan-connection keeps established. I'm pretty sure it's 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

share|improve this question

2 Answers 2

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

share|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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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