Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Server

Windows Server 2012 : Installing roles and features (part 2) - Installing roles and features using Windows PowerShell

9/12/2013 3:16:39 AM

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

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.

Quick check

  • What parameter of the Install-WindowsFeature cmdlet should you include if you want to force the targeted server to restart to complete the installation of a role or feature?

Quick check answer

  • Include the –Restart parameter.

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.

Other -----------------
- System Center Configuration Manager 2007 : Desired Configuration Management - Troubleshooting
- System Center Configuration Manager 2007 : Desired Configuration Management - DCM Strategies
- Microsoft Exchange Server 2007 : Leveraging the Capabilities of the Outlook Web Access Client - Understanding OWA Security Features, Tips for OWA Users with Slow Access
- Microsoft Exchange Server 2007 : Leveraging the Capabilities of the Outlook Web Access Client - Using Contacts in OWA
- What's new and improved in SharePoint 2013 : Creating an eDiscovery Center
- What's new and improved in SharePoint 2013 : Creating badges, Using Visual Designer for workflows within SharePoint Designer
- What's new and improved in SharePoint 2013 : Previewing search documents, Using the Community Site template
- Windows Small Business Server 2011 : Adding a Terminal Server - Adding a RemoteApp to Remote Web Workplace
- Windows Small Business Server 2011 : Adding a Terminal Server - Configuring RemoteApps (part 2) - Deploying with .rdp and .msi files
- Windows Small Business Server 2011 : Adding a Terminal Server - Configuring RemoteApps (part 1) - RemoteApp Manager
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

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

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
 
VIDEO TUTORIAL
- 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
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro