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.
Install all available Web features:
PS C:\> Get-WindowsFeature Web-* | Add-WindowsFeature
Install iis along with the .NET Framework v4.0, ASP.NET and the iis Management console:
PS C:\> Import-Module ServerManager
PS C:\> Add-WindowsFeature Web-Server, Web-Mgmt-Console, Web-Scripting-Tools, Web-Basic-Auth, Web-Windows-Auth, NET-FRAMEWORK-45-Core, NET-FRAMEWORK-45-ASPNET, Web-HTTP-Logging, Web-NET-Ext45, Web-ASP-Net45
Install both Telnet Server and Telnet Client:
PS C:\> Add-WindowsFeature Telnet-Server,Telnet-Client
"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.