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.
PowerShell offers an easier, more versatile alternative then with ‘Netsh‘ at the command line: Netsh interface set interface Disabled
Netsh interface set interface Disabled
Enumerate your network cards:
Get-NetAdapter | Format-Table Name, InterfaceDescription -Auto
Disable one of your network cards:
Disable-NetAdapter -Name 'Ethernet'
Enable your disabled network card:
For test purposes you may wish to ‘Enable’ the network card, and thus reverse the effect of Disable-NetAdapter.
Enable-NetAdapter -Name 'Ethernet'
Note: Before you launch PowerShell, right-click and Run it as Administrator.
Microsoft’s NetAdapter Cmdlet Family:
Get-Command -noun netadapter
PowerShell brings hundreds of new cmdlets. If you research the NetAdapter noun then you will see a family of Get, Enable and Disable-NetAdapter cmdlets.