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.
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.
Note
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).
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.
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.
Note
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.
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.