PowerShell Manage Windows Features and Roles

Server Core deployments, automated provisioning pipelines, and configuration management systems all require scripted role and feature installation — there is no GUI to click through. Understanding PowerShell windows features management lets you install IIS, .NET Framework, failover clustering, or any Windows Server role in a single command, repeat the deployment identically across dozens of servers, and capture the full configuration as code. This post covers listing, installing, and removing features on both Server and desktop Windows editions.
List Available Windows Features
On Windows Server, Get-WindowsFeature lists every available role and feature with its installation state. On Windows desktop editions, use Get-WindowsOptionalFeature via the DISM module instead:
# Windows Server — lists all roles and features
Get-WindowsFeature | Where-Object Installed -eq $true | Select-Object Name, DisplayName
# Show all available features (installed and not)
Get-WindowsFeature | Format-Table Name, DisplayName, Installed, InstallState -AutoSize
# Windows 10/11 — use DISM
Get-WindowsOptionalFeature -Online | Where-Object State -eq Enabled | Select-Object FeatureName
Name DisplayName Installed InstallState
---- ----------- --------- ------------
Web-Server Web Server (IIS) True Installed
NET-Framework-45-Core .NET Framework 4.5 True Installed
Hyper-V Hyper-V False Available
Install a Windows Feature
Install-WindowsFeature installs a role or feature by name. Use -IncludeManagementTools to also install the associated management PowerShell module and GUI snap-in:
$result = Install-WindowsFeature -Name 'RSAT-AD-Tools' -IncludeManagementTools
if ($result.Success) {
Write-Host "Installed successfully. Restart required: $($result.RestartNeeded)"
} else {
Write-Warning "Installation failed: $($result.FeatureResult)"
}
Installed successfully. Restart required: No
Install Web Server (IIS) Role
IIS installation with common sub-features needed for ASP.NET web applications:
$iisFeatures = @(
'Web-Server',
'Web-Common-Http',
'Web-Default-Doc',
'Web-Dir-Browsing',
'Web-Http-Errors',
'Web-Static-Content',
'Web-Asp-Net45',
'Web-Mgmt-Console'
)
$result = Install-WindowsFeature -Name $iisFeatures -IncludeManagementTools
Write-Host "Success: $($result.Success)"
Write-Host "Restart needed: $($result.RestartNeeded)"
if ($result.RestartNeeded -eq 'Yes') {
Write-Warning "A restart is required to complete IIS installation"
}
Remove a Windows Feature
Remove-WindowsFeature uninstalls a role or feature and its sub-features. The -Remove switch also deletes the feature’s payload files from disk, reducing the footprint but preventing future installation without access to installation media:
# Uninstall but keep payload (can reinstall without media)
Remove-WindowsFeature -Name 'Telnet-Client'
# Remove payload from disk permanently
Remove-WindowsFeature -Name 'Telnet-Client' -Remove
# Confirm what would be removed without making changes
Remove-WindowsFeature -Name 'Web-Server' -WhatIf
Desktop Features with DISM
On Windows 10 and 11, use Enable-WindowsOptionalFeature and Disable-WindowsOptionalFeature from the DISM module. These require an elevated session:
# Enable Telnet Client on Windows desktop
Enable-WindowsOptionalFeature -Online -FeatureName 'TelnetClient' -NoRestart
# Enable Windows Subsystem for Linux
Enable-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Windows-Subsystem-Linux' -NoRestart
# Disable a feature
Disable-WindowsOptionalFeature -Online -FeatureName 'TelnetClient' -NoRestart
# Check state
(Get-WindowsOptionalFeature -Online -FeatureName 'TelnetClient').State
Install Multiple Features from List
Read a feature list from a text file and install them all, then capture the results for auditing:
$featureList = Get-Content "C:\Config\required-features.txt"
$timestamp = Get-Date -Format 'yyyyMMdd_HHmmss'
$logFile = "C:\Logs\feature-install_$timestamp.log"
$results = Install-WindowsFeature -Name $featureList -IncludeManagementTools -LogPath $logFile
$results.FeatureResult | Select-Object Name, Message, RestartNeeded |
Export-Csv "C:\Reports\feature-install-results.csv" -NoTypeInformation
Write-Host "Install log: $logFile"
Write-Host "Overall success: $($results.Success)"
Common Errors and Fixes
-
Install-WindowsFeature only on Server — use DISM on desktop.
Install-WindowsFeatureis provided by theServerManagermodule, which only exists on Windows Server. On Windows 10/11, you will get a “cmdlet not found” error. UseEnable-WindowsOptionalFeature -Onlineinstead. -
Restart required after some feature installs. The return object from
Install-WindowsFeaturehas aRestartNeededproperty. Check it and restart withRestart-Computer -Forceif required. Some features do not become active until after a reboot.
Related Cmdlets / See Also
Wrapping Up
Use Get-WindowsFeature and Install-WindowsFeature on Windows Server, and the DISM *-WindowsOptionalFeature cmdlets on desktop Windows. Always check the RestartNeeded result property and include -IncludeManagementTools when installing server roles to also get the PowerShell management modules.


