Netsh
Netsh has been around for several versions of Windows and is used to
manage networking components on both local and remote computers. This
command-line tool and scripting shell can help troubleshoot, correct,
and automate working with network adapters and other components in
Windows.
Netsh allows many parameters, listed in Table 1, to help with different components and scripts, both locally and remotely.
Table 1. Netsh command options
Netsh command |
Details |
Help or ? |
Displays the help for Netsh |
Add helper |
Adds a Netsh helper DLL |
Delete helper |
Removes a Netsh helper DLL |
Show helper |
Lists the installed helper DLLs |
Cmd |
Starts a command-line session |
Online |
Sets Netsh to online mode |
Offline |
Sets Netsh to offline mode |
Set mode |
Changes the mode of Netsh to online or offline |
Show mode |
Displays the current mode of Netsh |
Flush |
Discards changes in offline mode |
Commit |
Saves changes in offline mode |
Set machine |
Selects the computer on which Netsh commands will run |
Exec |
Executes a script file with Netsh commands |
Quit, bye, exit |
Exits Netsh |
Add alias |
Creates an alias for an existing Netsh command |
Delete alias |
Removes an alias for an existing Netsh command |
Show alias |
Lists all existing Netsh aliases |
Dump |
Writes configuration to a text file |
Popd |
Script command that removes the current context from the Netsh stack |
Pushd |
Script command that pushes the active context onto the stack |
Netsh can help you accomplish many things. Many real-world examples work with network interfaces. Netsh can be used to modify the IP address or reset the TCP/IP stack for an adapter if the GUI is not available.
Windows Remote
Shell (WinRS) is designed to help you work on and troubleshoot problems
on remote Windows systems from the command line. It enables execution
of any shell-based commands that might work in the command shell
(Cmd.exe) against remote computer systems. Using WinRS can speed up performance of routine tasks because it doesn’t require visits to each machine.
Before using WinRS on computers in an environment, the computers must have Windows Remote Management (WinRM) configured to accept connections. The most straightforward way to accomplish this goal is as follows:
-
Open an elevated command prompt.
-
Type the command WinRM quickconfig and press Enter.
-
When the prompt appears asking if you’d like to accept the proposed changes, type Y and press Enter.
-
Await the return of a message indicating that the process was successful.
This command carries out the following actions:
-
Starts the WinRM service and sets the service startup type to auto-start
-
Configures a listener for the ports that send and receive WS-Management protocol messages using either HTTP or HTTPS on any IP address
-
Defines firewall exceptions for the WinRM service and opens the ports for HTTP and HTTPS
After WinRM has been configured, you can move on to managing WinRS.
The available switches for WinRS are:
-
-r[emote]:endpoint Tells WinRS to connect to a remote system when endpoint is the computer name for the remote system.
-
-un[encrypted] Determines whether the connection to the specified machine should be unencrypted.
-
-u[sername]:username Specifies the user name credential used to connect to the remote system.
-
-p[assword]:password Specifies the password for the credential needed to connect to the remote computer.
-
-d[irectory]:path Specifies the starting directory for WinRS on the remote system.
-
-env[ironment]:string=value
Sets an environment variable on the remote system when the session
begins. This switch supports multiple occurrences for multiple
environment variables.
-
-noe[cho] Disables echo or screen output. In some cases, answers to remote commands need not be displayed locally. Echo is turned on by default.
-
-nop[rofile]
Prevents the user profile from loading during the session. If the
connecting user is not an administrator on the local computer, the -nop
switch is required to prevent profiles from loading.
-
-comp[ression] Enables compression. This option is turned off by default because older computers might not support the option.
-
-[use]ssl
Connects to a remote computer by using a Secure Sockets Layer (SSL)
connection on the default WinRM port instead of HTTPS, which uses port
443.
-
-? WinRS help.
WinRS is useful for performing command-line tasks on remote
computers. Many administrators might already know these tasks and use
them frequently on local machines. Using WinRS will keep the syntax the
same for many commands so they can be executed easily on other systems.
Many of the commands available from the command line can also be
performed in Windows PowerShell, but in some cases, the syntax is different. WinRS can ease this learning curve.
The syntax for a WinRS command is as follows:
WinRS -r:Server02 cmd
Specify WinRS, and then use the -r switch with a computer name to
point the connection to a remote system and issue the command to open a
command prompt.
WinRM quickconfig
Using quickconfig will ready your system to accept connections on the remote management port.