Netsh Networking Shell Tutorial

Netsh Overview

Netsh, pronounced just as it’s spelt as “netch”, is a command line scripting utility that’s been around since Windows Server 2003. Although somewhat depreciated by cmdlets available in PowerShell, Netsh can allow you to view or change the network configuration of your local computer or a remote computer. Netsh can be run at the command line or built into a script inside of a batch file.

To start Netsh, open a command line shell or PowerShell and type:


How to Browse Netsh

Once inside Netsh, type “?” to see a list of commands available to you:

Note how it describes the list as “commands in this context”. Contexts are groups of commands available to you once you are inside of their context. Contexts can be nested in other Contexts and you’ll see it lists what sub-contexts are available. To get inside a context, just type its name, such as interface, and again a “?” will show you what commands area available to you in that context.

This is generally how you browse around. By opening contexts, typing “?” to see what is available, and typing sub-contexts to get even deeper until you find the command you want.

Also, note how it mentions that PowerShell should be used rather than Netsh for TCP/IP commands. This is true for most Netsh commands, so just keep in mind that, although useful, PowerShell has largely taken over Netsh.

Using Netsh to Manage Remote Servers and Workstations

While you’re still at the cmd line shell (net yet into Netsh), you can invoke Netsh against a remote computer by following this format:

Netsh -r <hostname> -u <domain\user> -p <password> <Netsh command>

In this example, we can see the IPV4 information on the remote computer 63769:

For the -r argument, you can supply the hostname as either the IP address, the hostname, or the FQDN of the remote host.

Running Commands in Netsh

The general syntax to run a netsh command is:

netsh[ -a AliasFile] [ -c Context ] [-r RemoteComputer] [ -u [ DomainName\ ] UserName ] [ -p Password | *] [{NetshCommand | -f ScriptFile}]

For example, to open a firewall port on a remote computer:

netsh –r WORKSTATION001 –u DOMAIN\User –P P@ssw0rd! advfirewall set portopening tcp 445 smb enable

Additionally, some commands require a parameter string. In the case where the parameter string requires a space, be sure to include it in quotes:

interface="Wireless Network Connection"

Popular Netsh Commands

  1. Show the IP configuration

    netsh interface ip show config
  2. Show IPv4 or IPv6 information

    netsh interface ipv6 show address
  3. Open a Firewall Port

    netsh advfirewall firewall
      add rule name="HTTPS"
      dir=in action=allow protocol=TCP localport=443
  4. Show Network Adapter Status

    netsh interface show interface
  5. Configure adapter for static IP Address

    netsh interface ip
      set address "Local Area Connection"
      static 1
  6. Configure adapter to use DHCP

    netsh interface ip 
      set dns "Local Area Connection" dhcp

Example Batch File

This is an example batch file:

netsh wins server add name Name=MY\_RECORD EndChar=04 IP={}

netsh wins server add partner Server= Type=2
netsh wins server add partner Server= Type=2
netsh wins server init push Server= PropReq=0
netsh wins server show name Name=MY\_RECORD EndChar=04

Leave a Comment

Your email address will not be published.