当前位置: 动力学知识库 > 问答 > 编程问答 >

How can I display , enable or disable all the Network adapters using powershell 5 in windows 7?

问题描述:

I am very new to Powershell. I am using Windows 7 and pwershell 5.

What I am trying to do is:

  1. display all the network adapters for a system.

  2. Disable all of them

  3. Enable all of them

I am using this code to display all the network adapters:

$wmi = get-wmiobject win32_networkadapter | select name, InterfaceIndex, netenabled

This displays all the network adapters and their status.

But the problem is that, I am not able to disable all pf the network adapters together using this command.

$wmi.disable()

This statement gives me the error:

Method invocation failed because [Selected.System.Management.ManagementObject] does not contain a method named 'disable'.

At line:1 char:1

+ $wmi.disable()

+ ~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (disable:String) [], RuntimeException

+ FullyQualifiedErrorId : MethodNotFound

Is there any alternative way to display all the network adapters and disable or enable all of them together ?

Thanks in advance!

分享给朋友:
您可能感兴趣的文章:
随机阅读: