PowerShell Disable-NetAdapter

PowerShell v 3.0 Disable Network AdapterDisable-NetAdapter

PowerShell version 3 makes it easier than ever to control your NIC (Network Interface Card) with Enable and Disable-NetAdapter cmdlets.

Tutorial for Disable-NetAdapter

 ♣

Scenarios for PowerShell's Disable-NetAdapter

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.

How to Disable One of Your Network Cards

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)Review of Orion NPM v11

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.

Download a free trial of Solarwinds' Network Performance Monitor

Enable Your Disabled Network CardDisable-NetAdapter

For testing purposes you may wish to 'Enable' the network card, and thus reverse the effect of Disable-NetAdapter.

# PowerShell script to enable your network card.
$YourNic = 'Wi-Fi'
Enable-NetAdapter -Name $YourNic
Restart-NetAdapter -Name $YourNic

Note 4:  Remember this: before you launch PowerShell 3.0 ISE, right-click and Run as Administrator.

Research Microsoft's NetAdapter Cmdlet Family

Get-Command -Noun netadapter

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

Troubleshooting Disable-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 MonitorFree Real-Time 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! 

Download your free network bandwidth monitor

If you need more comprehensive network analysis software:
Download a free trial of NPM (Network Performance Monitor)

Getting Started With PowerShell v 3.0Disable-NetAdapter

  • Launch PowerShell (Preferably the ISE version)
  • Copy the lines of code in the above examples (into memory).
  • Right-click in the top pane.
  • Paste.

More PowerShell v 3.0 Networking Cmdlets

One way to discover more about the new version 3 cmdlets is look at the 'Modules' in the Commands pane,  once the ISE has launched.

See more examples of PowerShell v 3.0 NetAdapter cmdlets ยป

Summary of PowerShell Disable-NetAdapter Cmdlet

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

 


See more Microsoft PowerShell v 3.0 examples

PowerShell 3.0  • What's New in PowerShell 3.0  • PowerShell v 3.0 ISE  • PowerShell Home

Get-NetAdapter  • Disable-NetAdapter  • Enable-NetAdapter  • Get-NetIPConfiguration

PowerShell Network Cmdlets  • PowerShell 3.0 Logon Script  • PowerShell Show-Command

 *


Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

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.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2014 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: