This post will provide you with the available NetSh command line switches and provide you with examples on how to use the utility.
NetSh is a network shell command line utility that allows you to display or even modify or otherwise change your Network Interface Card (NIC) settings or configuration on Microsoft windows XP or better local or remote Operating system machines.
With the NetSh utility you can also specify the command line arguments to run or execute a script so that you can execute multiple commands from the same execution with the –F switch followed by the script name.
NetSh Syntax And Command Switch Reference
The basic Syntax of the NetSh is shown directly below followed by a chart with the command line switch and a brief description of each.
NetSh [-a AliasFile] [-c Context] [-r RemoteComputer] [{NetshCommand|-f ScriptFile}]
Switch
Description
? or Help
Displays Help and provides this list of commands.
Add
Adds a new configuration entry to a list.
Bridge
Changes to the `NetSh Bridge' prompt context.
Delete
Deletes a configuration entry as opposed to Add entries.
Diag
Changes to the `NetSh Diag' prompt context.
Dump
Displays the contents of a configuration script.
Exec
Runs a script file.
Firewall
Changes to the `NetSh Firewall' prompt context.
Interface
Changes to the `NetSh Interface' prompt context.
Ras
Changes to the `NetSh Ras' prompt context.
Routing
Changes to the `NetSh Routing' prompt context.
Set
Updates configuration settings.
Show
Displays information available.
WinSock
Changes to the `NetSh WinSock' prompt context.
Using The NetSh Command Utility
To use the NetSh utility you need to open a command prompt window and enter NetSh in the command prompt and press Enter. Then you will be presented with the NetSh prompt NetSh> then enter your command as in the example below that will display or show your current mode for the local machine which should be online: Show Mode
If you want to use the NetSh utility from a remote machine at the prompt window and enter: Set Machine MachinName and the NetSh command prompt will change to [MachineName] NetSh> and at this point the utility behaves as if you were at the remote machine.
Tip: To exit the utility enter Bye rather than closing the window manually then the utility will exit and you will once again be returned to the command prompt window where you can enter Exit.
NetSh Examples
To determine which NIC card is currently using an IP address from the NetSh command prompt window enter Interface and press enter and you will be presented with the NetSh prompt: NetSh Interface>. Then enter IP Show Config.
To change a machine from a static IP address to a DHCP client issue the following using the steps show above. From the NetSh Interface> prompt enter: IP Set Address "Local Area Connection" DHCP
To open the Webpage Graphical Interface (GUI) for the NetSh utility at the NetSh Prompt enter: NetSh Diag GUI
To view your Firewall configuration from the NetSh command prompt window enter Firewall and press enter and you will be presented with the NetSh prompt: NetSh Firewall> and then enter Show Service.
Note: You can also send the results of your commands to a text file with the > redirector such as NetSh Diag GUI > NetShDiag.Txt
Additional Information
Managing Windows 2000 Networking Components with NetSh
http://www.microsoft.com/technet/community/columns/cableguy/cg1101.mspx
In Server Core installations of Windows Server 2008 the Windows Firewall is enabled by default. This