Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

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

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
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
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server