PowerShell Tip: Control your NIC (Network Interface Card)

powershell-logoThere 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s