Managing Windows Server 2012 (part 3) - Working with the administration tools - Using command-line utilities

12/19/2013 3:08:07 AM

1.3 Using command-line utilities

Many command-line utilities are included with Windows Server 2012. Most of the utilities you’ll work with as an administrator rely on TCP/IP. Because of this, you should install TCP/IP networking before you experiment with these tools.

Utilities to know

As an administrator, you should familiarize yourself with the following command-line utilities:

  • Appcmd Displays and manages the configuration of IIS.

  • Arp Displays and manages the IP-to-physical address mappings used by Windows Server 2012 to send data on the TCP/IP network.

  • Bcdedit Displays and manages Boot Configuration Data on the local system.

  • DiskPart Displays and manages disk partitions on local and remote systems.


    Windows 8 and Windows Server 2012 might be the last versions of Windows to support Disk Management, DiskPart, and DiskRaid. The Virtual Disk Service (VDS) COM interface is being superseded by the Storage Management API. You can continue to use Disk Management and DiskPart to manage storage. These tools cannot be used to manage Storage Spaces, nor can the cmdlets in the Storage module for PowerShell be used to manage dynamic disks. Dynamic disks also are being phased out in favor of Storage Spaces and might not be available in future versions of Windows.

  • Dnscmd Displays and manages the configuration of DNS services.

  • Ftp Starts the built-in FTP client.

  • Hostname Displays the computer name of the local system.

  • Ipconfig Displays the TCP/IP properties for network adapters installed on the system. You can also use it to renew and release DHCP information.

  • Nbtstat Displays statistics and current connections for NetBIOS over TCP/IP.

  • Net Displays a family of useful networking commands.

  • Netsh Displays and manages the network configuration of local and remote computers.

  • Netstat Displays current TCP/IP connections and protocol statistics.

  • Nslookup Checks the status of a host or IP address when used with DNS.

  • Pathping Traces network paths, and displays packet loss information.

  • Ping Tests the connection to a remote host.

  • Route Manages the routing tables on the system.

  • Schtasks Displays and manages scheduled tasks on local and remote systems.

  • Tracert During testing, determines the network path taken to a remote system.

  • Wbadmin Performs backup and recovery operations, including system state recovery and recovery of any type of disk to an alternate location. Also gets disk details, including name, GUID, available space, and related volumes.

  • Wevtutil Displays and manages event logs on local and remote systems.

To learn how to use these command-line tools, type the name at a command prompt followed by /?. Windows Server 2012 then provides an overview of how the command is used (in most cases).

Using Net tools

You can more easily manage most of the tasks performed with the Net commands by using graphical administrative tools and Control Panel utilities. However, some of the Net tools are very useful for performing tasks quickly or for obtaining information, especially during telnet sessions to remote systems. These commands include the following:

  • Net Start Starts a service on the system.

  • Net Stop Stops a service on the system.

  • Net Time Displays the current system time, or synchronizes the system time with another computer.

  • Net Use Connects and disconnects from a shared resource.

  • Net View Displays a list of network resources available to the system.

To learn how to use any of the Net command-line tools, type net help at a command prompt followed by the command name, such as net help start. Windows Server 2012 then provides an overview of how the command is used.

Using Windows PowerShell

Windows PowerShell is installed by default with Windows Server 2012. PowerShell is a full-featured command shell that can use built-in commands called cmdlets and built-in programming features, as well as standard command-line utilities. Normally, PowerShell is installed by default on Windows Server 2012 and on Windows 8 Pro and Windows 8 Enterprise. If so, you can run Windows PowerShell, using the following techniques:

  • From Start, a quick way to open Windows PowerShell is to type powershell and press Enter.

  • From Desktop, PowerShell is normally pinned to the taskbar, enabling you to run PowerShell simply by tapping or clicking the related taskbar button.


If Windows PowerShell is not installed, you can install it as a feature of the operating system. In Windows Server 2012, use the Add Features And Roles Wizard. In Windows 8, use Control Panel to turn on Windows PowerShell as a feature.

After starting Windows PowerShell, you can enter the name of a cmdlet at the prompt and it will run in much the same way as a command-line command. You can also execute cmdlets from within scripts. Cmdlets are named using verb-noun pairs. The verb tells you what the cmdlet does in general. The noun tells you what specifically the cmdlet works with. For example, the get-variable cmdlet either gets all Windows PowerShell environment variables and returns their values or gets a specifically named environment variable and returns its values. These are the common verbs associated with cmdlets:

  • Get- Queries a specific object or a subset of a type of object, such as a specified mailbox or all mailbox users.

  • Set- Modifies specific settings of an object.

  • Enable- Enables a setting or mail-enables a recipient.

  • Disable- Disables an enabled setting or mail-disables a recipient.

  • New- Creates a new instance of an item, such as a new mailbox.

  • Remove- Removes an instance of an item, such as a mailbox.

At the Windows PowerShell prompt, you can get a complete list of cmdlets available by typing help *-*. To get help documentation on a specific cmdlet, type help followed by the cmdlet name, such as help get-variable.

All cmdlets have configurable aliases as well, which act as shortcuts for executing cmdlets. To list all aliases available, type get-item –path alias: at the PowerShell prompt. You can create an alias that invokes any command using the following syntax:

new-item -path alias:AliasName -value:FullCommandPath

Here, AliasName is the name of the alias to create, and FullCommandPath is the full path to the command to run, such as:

new-item -path alias:sm -value:c:\windows\system32\compmgmtlauncher.exe

This example creates the alias sm for starting Server Manager. To use this alias, you simply type sm and then press Enter when you are working with PowerShell.

Running Windows commands at the PowerShell prompt

Increasingly administrators are using Windows PowerShell as their go-to prompt for entering both standard Windows commands and Windows PowerShell commands. Although it is true that anything you can type at a command prompt can be typed at the Windows PowerShell prompt, you need to understand the caveats that apply. Windows PowerShell looks for external commands and utilities as part of its normal processing. As long as the external command or utility is found in a directory specified by the PATH environment variable, the command or utility is run as appropriate. However, keep in mind Windows PowerShell execution order could affect whether a command runs as expected. For Windows PowerShell, the execution order is as follows:

  1. Alternate built-in or profile-defined aliases

  2. Built-in or profile-defined functions

  3. Cmdlets or language keywords

  4. Scripts with the .ps1 extension

  5. External commands, utilities, and files

Thus, when you run a Windows command from the PowerShell prompt, you have to ensure that no element in 1 to 4 of the execution order has the same name as the Windows command you want to run. If an element has the same name, that element will run instead of the expected command.

Resolving passthrough problems

When you are working with the PowerShell prompt, arguments you pass in with commands won’t be handled as expected. The reason for this is that PowerShell doesn’t pass the arguments through in the same way as the command prompt expects them. To resolve this and make it possible to pass in arguments with Windows commands run at the PowerShell prompt, you must enclose the arguments in single quotation marks.
Top 10
Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
3 Tips for Maintaining Your Cell Phone Battery (part 1) - Charge Smart
OPEL MERIVA : Making a grand entrance
FORD MONDEO 2.0 ECOBOOST : Modern Mondeo
BMW 650i COUPE : Sexy retooling of BMW's 6-series
BMW 120d; M135i - Finely tuned
PHP Tutorials : Storing Images in MySQL with PHP (part 2) - Creating the HTML, Inserting the Image into MySQL
PHP Tutorials : Storing Images in MySQL with PHP (part 1) - Why store binary files in MySQL using PHP?
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
Popular Tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS