2007-09-13

Enabled / Disable Network Adapter with Powershell

All i wanted to do was enable a network connection using powershell.

But unfortunately the easy way only works on Vista, and i needed it in Windows Server 2003. http://blogs.msdn.com/daiken/archive/2007/02/09/enable-disable-network-connection.aspx

I had to go digging around for how you used to have to enable the connection with wsf. http://mcpmag.com/columns/article.asp?EditorialsID=619

And then converted it into something i could use in powershell.

$shell = New-Object -comObject Shell.Application
((($shell.NameSpace(3).Items() | where {$_.Name -eq "Network Connections"}).GetFolder.Items() | where {$_.Name -eq "Local Area Connection"}).Verbs() | where {$_.Name -eq "En&able"}).DoIt()

And to disable.

$shell = New-Object -comObject Shell.Application
((($shell.NameSpace(3).Items() | where {$_.Name -eq "Network Connections"}).GetFolder.Items() | where {$_.Name -eq "Local Area Connection"}).Verbs() | where {$_.Name -eq "Disa&ble"}).DoIt()

At must have had at least 30 tabs open in my browser by the time i got this to work.

12 comments:

Anonymous said...

IS NOT WORK UNDER XP AND PORESHELL 1.0

Anonymous said...

I apologise, but, in my opinion, you are mistaken. Write to me in PM, we will discuss.

Anonymous said...

Hello, you site is very funny he told me to cheer up .. Merry Christmas.

Anonymous said...

NOW YOU CAN PERFORM LIKE A YOUNG LIONONCE AGAIN!

It’s true: we’re all getting older. And while some say age is all in the mind, it does sometimes show

in the body — when you can’t seem to perform the same in the bedroom as you used to. Now there’s

Excel, an all-natural solution to your woes between the sheets.

We’ve carefully blended a proven mix of herbs that will take years off your age, letting you perform

in bed like the young lion you once were. You’ll feel like you’re back in your 20s — or even younger —

after taking Excel for just a few short weeks. And renewed sexual prowess won’t be your only benefit:

you’ll also feel less anxious, more relaxed, and healthier overall, thanks to the bonus properties of

our 100% pesticide-free herbal ingredients. Some of our ingredients, long used as aphrodisiacs around

the world, even intensify the pleasure you feel at your partner’s touch. Imagine all of these benefits

— with no side effects to speak of!

Anonymous said...

Wow, that's crazy man. They should really try to do something to fix that.

Anonymous said...

Kory FAIL!

Anonymous said...

Really interesting article. Hope to see same more!

Anonymous said...

J'ai appris des choses interessantes grace a vous, et vous m'avez aide a resoudre un probleme, merci.

- Daniel

Anonymous said...

Thanks for the post. Good information for me.

Anonymous said...

Hey, I am checking this blog using the phone and this appears to be kind of odd. Thought you'd wish to know. This is a great write-up nevertheless, did not mess that up.

- David

Anonymous said...

What's up everyone, it's my first go to see at this website,
and piece of writing is really fruitful in favor of me, keep up posting these articles.


my webpage: online graduate certificates

Anonymous said...

Dear friends, when I keep not asked for secure anyone to mitigate, but energy is such a diabolical act, that
would rather to ask for help. I'm in a very grave position, expect Your friends, escape
they can, how much can. I want be deeply grateful to You.
Perfect Money U 1557851 E 1512655 correspondence: alexxx767@gmail.com
PayPal : alexxx767@gmail.com