1. Prerequisites for installing roles and features
To install a role or feature on a server running Windows Server
2012, the server must have access to the binaries for installing that
role or feature. A new capability called Features On Demand allows administrators to
completely remove the binaries for roles and features from a server
running Windows Server 2012 to reduce the amount of disk space the
operating system uses.
If the binaries for a particular role or feature you want to
install on a server have previously been removed from the server’s
system drive, Windows Server 2012 can obtain these binaries in several
ways:
-
By downloading them directly from Windows Update.
-
By copying them from the side-by-side store (SxS) folder on
a running installation of the same edition and service pack level
as your server. To do this, share the SxS folder or a parent
folder on the other server and then specify the UNC path to the
shared SxS folder when using the Add Roles And Features Wizard or
the Install-WindowsFeature cmdlet.
-
By copying the entire side-by-side store (SxS) folder of an
installation of the same edition and service pack level as your
server to a shared folder on a file server on your network. Then
specify the UNC path to this shared folder when using the Add
Roles And Features Wizard or the Install-WindowsFeature
cmdlet.
-
By using a mounted Windows image from a Windows Image (WIM)
file such as the Install.wim file in the \Sources folder on the
Windows Server 2012 product media (ISO file).
-
By using a mounted virtual hard disk file that includes an
installation of the same edition and service pack level as your
server.
You can use Group Policy to control whether removed binaries are
downloaded from Windows Update or not, and you can specify the path
where the binaries can be found if their associated roles or features
need to be installed. The policy setting for controlling this behavior
is as follows:
Computer Configuration\Policies\Administrative
Templates\System\Specify Settings For Optional Component
Installation And Component Repair
Figure 1
shows the configuration options for this policy setting.
Note
2. Installing roles and features using Server Manager
In previous versions of Windows Server, you could use the Add
Roles Wizard and Add Features Wizard to install roles and features,
respectively, on the server. Windows 2012 now includes a single
redesigned Add Roles And Features Wizard that provides greater
flexibility and control for installing roles and features on servers.
This wizard provides an easy way for administrators of small to
midsized organizations to install roles and features on servers
running Windows Server 2012 in their environment.
To use Server Manager to install a role or a feature on a server
running Windows Server 2012, begin by clicking the Manage menu and
selecting Add Roles And Features to open the Add Roles and Features
Wizard. The Select Installation Type page of this wizard shown in
Figure 2 offers two
options for installing roles and features on the server:
-
Role-based or feature-based
installation This option is similar to that used in
previous versions of Windows Server for installing the specific
roles or features you choose.
-
Remote Desktop Services
installation With this option, you can deploy a complete
Remote Desktop Services infrastructure, either for session-based
desktops or virtual desktops, on either a single server or
multiple servers.
Choosing the first option on the Select Installation Type page
leads to the Select Destination Server page of the wizard (shown in
Figure 3), which
you use to choose a remote server from your server pool on which to
install roles and features. Note that this page includes an option for
selecting an offline virtual hard disk instead of an online server. In
Windows Server 2012, you now can install roles and features on offline
virtual hard disks.
On the Select Server Roles page, shown in Figure 4, you can choose
one or more roles to install on the selected server. When you do this,
the wizard might prompt you to install the remote Server
Administration Tools for that role or feature plus any other
management tools needed for managing the role or feature.
The Select Features Page is next, and you use it to choose
features to install on your server. Additional wizard pages might also
be displayed to provide you with additional information or
configuration options for the roles and features you decide to install
on the server, or a list of role services to choose from for the
particular roles you are installing.
When you reach the Confirm Installation Selections page, shown
in Figure 5, you can
select the check box if you want the remote server to be restarted if
this is needed to complete installation of the selected roles and
features.
At the bottom of the Confirm Installation Selections page shown
in Figure 5 is a Specify
An Alternate Source Path link. Click this link if you previously
removed any of the binaries for the roles or features you are
installing on the server. Clicking this link displays a Specify
Alternate Source Path dialog box for specifying the UNC path to the
location where you can find the binaries needed to install the roles
or features.
When a new role is installed on the server, a new page for this
role is added to the Server Manager console. For example, Figure 6 shows the Print
Services page, which appears once the Print And Document Services role
has been installed on one or more servers in your server pool. A new
tile named Print Services also appears on the Dashboard so that you
can monitor events, services, and the performance of your print
servers and confirm their manageability.
The notification flag in the menu bar of Server Manager in Figure 6 indicates that
one informational notification has been raised. Clicking this flag
provides brief summary information concerning this notification, which
indicates that installation of the selected feature has been
successful.
3. Installing roles and features using Windows PowerShell
You can also install roles and features on servers running
Windows Server 2012 by using Windows PowerShell commands. This
approach can be useful for administrators who work in midsized to
large environments that have many servers deployed—for example, in a
datacenter. You can also use PowerShell to install roles and features
on offline virtual disks.
The following Server Manager cmdlets can be used for managing
roles and features using PowerShell:
-
Get-WindowsFeature Retrieves
information about Windows Server roles, role services, and
features that are available
-
Install-WindowsFeature
Installs one or more Windows Server roles, role services, or
features
-
Uninstall-WindowsFeature
Uninstalls and removes specified Windows Server roles, role
services, and features
Important
Running Server Manager cmdlets
Server Manager cmdlets must be run elevated.
Retrieving a list of installed roles and features
You can use the Get-WindowsFeature cmdlet to retrieve
information about roles, role services, and features available on a
remote server. For example, the following command displays a list of
all available roles and features and their current install state on
server SEA-SRV-1:
Get-WindowsFeature -ComputerName SEA-SRV-1
To display a list of all installed roles and features on the
server, pipe the output of the preceding command into the
Where-Object cmdlet and use Where-Object to filter out everything
except roles and features whose InstallState
property is equal to Installed:
Get-WindowsFeature -ComputerName SEA-SRV-1 | Where-Object InstallState -eq Installed
You can narrow your results even further by using the
–name parameter of the Get-WindowsFeature
cmdlet to select only roles and features that begin with “Print”like
this:
Get-WindowsFeature -Name Print* -ComputerName SEA-SRV-1 | Where-Object InstallState -eq
Installed
The output from running this command against server SEA-SRV-1
verifies that the Print Server role service of the Print And
Document Services role is installed:
Display Name Name Install State
------------ ---- -------------
[X] Print and Document Services Print-Services Installed
[X] Print Server Print-Server Installed
Note
REAL WORLD Windows PowerShell
3.0 simplified syntax
One of the improvements in version 3.0 of Windows PowerShell
is the simplification of the syntax for the Where-Object cmdlet.
If you are an administrator who already has some familiarity with
using PowerShell for managing Windows servers, you might have
wondered about the syntax of some of the commands in this section.
In particular, you might have wondered why the second example
didn’t look like this:
Get-WindowsFeature - ComputerName SEA-SRV-1 | Where-Object {$_.InstallState -
eq Installed}
The reason is because Windows PowerShell 3.0 lets you
eliminate the script block notation (the curly braces), the
current object placeholder ($_), and the dot property notation.
These improvements make PowerShell code easier to
understand.
Installing roles and features
You can use the Install-WindowsFeature cmdlet to install
roles, role services, and features available on a remote server. You
can also use the alias Add-WindowsFeature to invoke this command.
For example, the following command installs the DHCP Server role on
server SEA-SRV-1:
Install-WindowsFeature -Name DHCP -ComputerName SEA-SRV-1
The output from running the preceding command looks like
this:
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {DHCP Server}
To install the DHCP Server role together with the management
tools for this role, add the
–IncludeManagementTools parameter to the
preceding command. If a restart is required for the installation of
a role or feature to install properly, you can force this to happen
by including the –Restart parameter in the
command.
To install all of the Remote Server Administration features on
this server, use this command:
Install-WindowsFeature -Name RSAT -IncludeAllSubFeature -ComputerName SEA-SRV-1
Note
MORE INFO For more examples
of how to use the Install-WindowsFeature cmdlet, type Get-Help Install-WindowsFeature –examples
in the PowerShell console.
Installing roles and features on multiple servers
Although Server Manager can be used to install roles and
features only on a single server at a time, you can use PowerShell
to install roles and features on multiple computers at the same
time. You can do this by using the Invoke-Command cmdlet to run the
Install-WindowsFeature command on multiple computers. For example,
this command installs the XPS Viewer feature on servers SEA-SRV-1
and SEA-SRV-3:
Invoke-Command -ComputerName SEA-SRV-1, SEA-SRV-3 -ScriptBlock {Install-WindowsFeature -
Name XPS-Viewer}
The output from running the preceding command looks like
this:
Success Restart Needed Exit Code Feature Result PSComputerName
------- -------------- --------- -------------- --------------
True No Success {XPS Viewer} SEA-SRV-1
True No Success {XPS Viewer} SEA-SRV-3
Note
Installing and removing roles or features from multiple
computers
You can use the Invoke-Command with the Server Manager
cmdlets to install or remove roles or features on only up to 32
computers at a time. If you specify more than 32 computers, the
additional computers will be queued. You can use the
ThrottleLimit parameter to override this
behavior.
Installing roles and features for which the payload has been
removed
If the binaries for the role or feature you want to install
have been removed from the server, you can use the
–Source parameter to specify the location of
the binaries needed to install the role or feature. If you don’t
specify this parameter, the necessary binaries will be downloaded
from Windows Update unless this behavior has been disabled using
Group Policy. Note that downloading role or feature binaries from
Windows Update can take some time.
4. Removing roles and features
Roles and features can be removed from a remote server by using
either Server Manager or PowerShell:
-
To remove roles or features using Server Manager, select
Remove Roles And Features from the Manage menu and complete the
steps of the Remove Roles And Features Wizard.
-
To remove roles or features using PowerShell, use the
Uninstall-WindowsFeature cmdlet or its alias
Remove-WindowsFeature. For more help on using this cmdlet, type
Get-Help Uninstall-WindowsFeature
–Detailed at a PowerShell prompt.