Installing Windows features from the command-line with PowerShell
Posted: (EET/GMT+2)
Many Windows features can be installed from the Settings UI, but for automation, scripting, and server work, PowerShell is usually more convenient. Windows 10 and Windows Server provide a set of cmdlets for installing optional features, roles, and components.
To list all available optional Windows features, run the following command:
Get-WindowsOptionalFeature -Online
To enable one of the features (by name), run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
On Windows Server, roles and features are managed through the
ServerManager module:
Get-WindowsFeature Install-WindowsFeature Web-Server
Running these from scripts is a nice way to configure new servers quickly or ensure your development machine always has the tools you need. I also use these cmdlets when provisioning virtual machines that must be consistent across different environments.