Install specified roles, role services, and features on a computer running Windows Server 2008 R2 for 2012 R2 use Install-WindowsFeature.
Syntax
Add-WindowsFeature [-Name] string[] [-IncludeAllSubFeature] [-logPath string]
[-WhatIf] [-Restart] [-Concurrent] [CommonParameters]
Key
-Name string
The command IDs of roles, role services, or features to install.
Alternatively, an array of Feature objects will also be accepted.
You can find a list of command IDs for all roles, role services, and features in the
topic "Overview of Server Manager Commands" in the Server Manager Help.
-IncludeAllSubFeature
Specifies the installation of all subordinate services and features along
with the parent role, role service, or feature named in the -Name parameter.
-logPath string
The name and location of a log file, other than the default, %windir%\logs\ServerManager.log.
-WhatIf
Describe what would happen if you executed the command, without actually
executing the command. This will also display any Windows features that
would be installed due to dependencies.
-Restart
Restart the computer automatically when installation is complete,
if restarting is required by the roles or features installed.
-Concurrent
Allow concurrent instances of Add-WindowsFeature or Remove-WindowsFeature
to run at the same time. Do not add this parameter unless you are installing
roles, role services, or features that are downloaded separately from
Windows Server 2008 R2, and you want to install Windows features on which
the downloaded technology depends at the same time. The use of this switch is not recommended.
This switch is intended for out-of-band feature(s) to install their dependencies.
-passThru SwitchParameter
Pass the newly-extended object created by this cmdlet along the pipeline.
For most objects, Add-Member adds the new members to the input object. However,
when the input object is a string, Add-Member cannot add the member to the input object.
For these objects, use the PassThru parameter to create an output object.
In PowerShell 2.0, Add-Member added members only to the PSObject wrapper of objects, not to the object.
Use -PassThru to create an output object for any object that has a PSObject wrapper.
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.
Examples
Install both Telnet Server and Telnet Client:
C:\PS> Add-WindowsFeature Telnet-Server,Telnet-Client
Install all Web features:
C:\PS> Get-WindowsFeature Web-* | Add-WindowsFeature
"What we think, we become" ~ Siddhartha Gautama (Buddha)
Related PowerShell Cmdlets:
Add-WindowsCapability - Install a Windows capability package on the specified OS image.
Get-WindowsFeature - Retrieve roles, role services, and features.
Enable-WindowsOptionalFeature - Enable a feature in a Windows image.
Remove-WindowsFeature - Remove roles, role services, and features.