There are scenarios where you would need to disable a network adapter,
for example controlling Wi-Fi usage.
On the other hand, there are situations where your computer has multiple
NICs and you want to choose which one is active.
Windows PowerShell v 3.0 offers an easier, more versatile alternative to grappling with 'Netsh' at the
command line: Netsh interface set interface <NIC Name> Disabled
The only problem with PowerShell's Disable-NetAdapter is that you need
to know the Name of your NIC. This is where the sister cmdlet
Get-NetAdapter is handy.
Discover the Names of Your NICs
# PowerShell script to enumerate your network cards. Get-NetAdapter
| Format-Table Name, InterfaceDescription -Auto
Note 1: You can research more properties by
appending |
Get-Member.
Preliminary step: before you launch PowerShell, right-click and 'Run as
Administrator'.
# PowerShell script to disable your network cards.
Disable-NetAdapter -Name 'Wi-Fi'
Note 2: Most likely you need to change the
name 'Wi-Fi' for the name of your network card revealed by the Discover
script above.
Note 3: You can omit the -Name parameter as
PowerShell v 3.0 assumes that the word after NetAdapter is indeed the name of
the NIC.
Guy Recommends: A Free Trial of the Network Performance Monitor
(NPM)
SolarWinds'
Network Performance Monitor
will help you discover what's happening on your network. This
utility will also guide you through troubleshooting; the dashboard will
indicate whether the root cause is a broken link, faulty equipment or
resource overload.
What I like best is the way NPM suggests solutions to network
problems. Its also has the ability to monitor the health of individual VMware
virtual machines. If you are interested in troubleshooting, and creating
network maps, then I recommend that you try NPM now.
CommandType Name
ModuleName -----------
------
------------ Function Disable-NetAdapter NetAdapter Function
Enable-NetAdapter NetAdapter Function Get-NetAdapter
NetAdapter Function Rename-NetAdapter NetAdapter Function
Restart-NetAdapter NetAdapter Function Set-NetAdapter
NetAdapter
If you don't have the cmdlet / function called Disable-NetAdapter, then
firstly, check that your version of PowerShell is v 3.0. It also
seems that this cmdlet is only available in Windows 8 and Server 2012.
Guy
Recommends:
SolarWinds Free Network Bandwidth Monitor
This freeware monitor is great for checking whether your network's load-balancing is performing as
expected, for example, are two interfaces are getting about equal
traffic?
It's easy to install and straightforward to configure. You will
soon be running tests to see how much network bandwidth your
applications consume.
The GUI has a lovely balance between immediate network traffic data in
the middle, combined with buttons to seek related data and configuration
settings. Give this monitor a try, it's free!
PowerShell version 3 brings hundreds of new cmdlets. If you
research the NetAdapter noun then you will see a family of Get, Enable and
Disable-NetAdapter cmdlets.
If you like this page then please share it with your friends
Windows Management Instrumentation (WMI) is
most useful for PowerShell scripting.
SolarWinds
have produced this
Free WMI Monitor to take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.