Enable/Disable a Network Connection using WMIC, NETSH and POWERSHELL

The network interface controller (NIC) is a hardware card that allows a PC to participate in passing and receiving data on a network. An NIC is commonly referred to as an NIC card, LAN card, LAN adapter, network card, network adapter, Ethernet adapter, and a few other names. Often the name may be a reference to technology the NIC is supporting (i.e., an Ethernet card).

NIC cards operate at Layers 1 and 2 of the OSI reference model. Because NIC is a physical connecting device, providing a user with network access, it is a Layer 1 device. However, because it uses a system for addressing nodes, it is also a Layer 2 device.

Many newer laptops and tablets have either a switch or a hotkey setting that enables and disables the network device but you can do the same in windows 10 by following 3 ways:

  1. Enable/Disable Network Connection with WMIC
  2. Enable/Disable Network Connection with NETSH
  3. Enable/Disable Network Connection with POWERSHELL

1. Enable/Disable Network Connection with WMIC

Windows Management Instrumentation Command-line (WMIC), which uses the power of Windows Management Instrumentation (WMI) to enable systems management from the command line . WMIC extends WMI for operation from several command-line interfaces and through batch scripts. Before WMIC, you used WMI-based applications (such as SMS), the WMI Scripting API, or tools such as CIM Studio to manage WMI-enabled computers.

To list out all the network devices/adapters, type the following command in command prompt (with Administrative Permissions) –

Command: wmic nic get name, index

WMIC uses global switches, aliases, verbs, commands, and command-line help to empower the interface. Global switches are settings that apply to and for the entire WMIC session.

In case, if you want to know how your computer treats any specific NIC adapter, add “NetConnectionID” to the above WMIC command as shown below:

Command: wmic nic get name, index, NetConnectionID

Now to disable NIC (Index 12 – Interl(R) Ethernet Connection (2) I219-LM), use the following command:

Command: wmic path win32_networkadapter where index=12 call disable

And to enable the same NIC with wmic, the command is:

Command: wmic path win32_networkadapter where index=12 call enable

You can also use the adapter name instead of index number. For example if you want to disable the Wireless Adapter whose name is “Wi-Fi”, then the command is:

Command: wmic path win32_networkadapter where NetConnectionID=”Wi-Fi” call disable

To enable the wireless adapter, the command is:

Command: wmic path win32_networkadapter where NetConnectionID=”Wi-Fi” call enable

2. Enable/Disable Network Connection with NETSH

Netsh is a command-line scripting utility that allows you to display or modify the network configuration of a computer that is currently running. Netsh commands can be run by typing commands at the netsh prompt and they can be used in batch files or scripts. Remote computers and the local computer can be configured by using netsh commands.

To list all the network devices/adapters, the command is:

Command: netsh interface show interface

To enable/disable the Wireless Network Connection, the commands are:

Command: netsh interface set interface “Wi-Fi” disabled
Command: netsh interface set interface “Wi-Fi” enabled

You can obtain a list of netsh contexts by opening either command prompt or Windows PowerShell on a computer running Windows Server 2016 or Windows 10 with command under netsh prompt /?

PS C:\Windows\system32> netsh
netsh>/?

3. Enable/Disable Network Connection with POWERSHELL

Windows PowerShell always marks a significant advance for the Windows network administrator. Combining the power of a full-fledged scripting language with access to command-line utilities, Windows Management Instrumentation (WMI), and even VBScript, Windows PowerShell provides the power and ease of use that have been missing from the Windows platform since the beginning of time.

To print the list of all available adapters, the command is:

Command: Get-NetAdapter

The Get-NetAdapter cmdlet gets the basic network adapter properties. To see the common network adapter properties, pipe the output into the Format-List cmdlet.

To enable/disable the network interface with the required name: (for example: Wi-Fi), the command is:

Command: Get-NetAdapter -Name Wi-Fi | Disable-NetAdapter -Confirm:$false
Command: Get-NetAdapter -Name Wi-Fi | Enable-NetAdapter

You may also like:

Sarcastic Writer

Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.

Related Posts