Resolving Missing Install-WindowsFeature Cmdlet in PowerShell on Windows 10: IIS Deployment Workarounds


2 views

The Install-WindowsFeature cmdlet (and related *-WindowsFeature commands) are part of the Server Manager module in Windows Server editions. These commands were intentionally excluded from Windows 10 because:

  • Windows 10 is a client OS, not designed for server roles
  • The underlying DISM infrastructure differs between client/server SKUs
  • Microsoft's "Server Core" concept doesn't apply to desktop Windows

For local development environments, consider these approaches:

# Option 1: Using DISM directly
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerRole" -All -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServer" -All -NoRestart

# Option 2: Chocolatey package manager (requires admin)
choco install iis-express --params="/fulldir:C:\IISExpress"

# Option 3: Docker containers (cross-platform compatible)
docker run -d -p 80:80 --name my-iis mcr.microsoft.com/windows/servercore/iis

For scripts needing to work across both Windows 10 and Server:

function Install-IISComponents {
    param([switch]$ServerEdition)

    if ($ServerEdition) {
        Install-WindowsFeature -Name Web-Server -IncludeManagementTools
    }
    else {
        $features = @(
            "IIS-WebServerRole",
            "IIS-WebServer",
            "IIS-CommonHttpFeatures",
            "IIS-ManagementConsole"
        )
        
        foreach ($feature in $features) {
            Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart
        }
    }
}

# Usage example:
Install-IISComponents -ServerEdition ($env:OS -like "*Server*")

For automated environments, these methods work consistently:

  • Azure DevOps: Use the IISWebAppManagement task
  • GitHub Actions: Leverage setup-dotnet with IIS Express
  • Packer templates: Separate builders for client/server images

If features won't enable, check:

# Verify available features
Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -like "IIS-*" }

# Repair corrupted components:
DISM /Online /Cleanup-Image /RestoreHealth
sfc /scannow
Component Windows Server Windows 10
Management Console Server Manager Turn Windows Features On/Off
Command Line Install-WindowsFeature Enable-WindowsOptionalFeature
Underlying Tech Server Core packages Optional Features

When migrating PowerShell scripts from Windows Server to Windows 10 for environment setup, many developers encounter a frustrating roadblock: the Install-WindowsFeature cmdlet (and related Server Manager commands) are completely missing. This is particularly problematic for scripts that configure IIS or other Windows features during development environment provisioning.

The Install-WindowsFeature cmdlet belongs to the ServerManager module, which is deliberately excluded from Windows 10/11 client SKUs. Microsoft designed these commands specifically for Windows Server environments.

# This will fail on Windows 10:
Install-WindowsFeature -Name Web-Server -IncludeManagementTools

For Windows 10 development environments, you should use the Enable-WindowsOptionalFeature cmdlet instead. Here's how to convert your existing scripts:

# Old Server version:
# Install-WindowsFeature -Name Web-Server -IncludeManagementTools

# Windows 10 equivalent:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole -NoRestart

The feature names differ between Server and Client Windows versions. Here are common mappings:

Windows Server Feature Windows 10 Equivalent
Web-Server IIS-WebServer
Web-Mgmt-Tools IIS-ManagementConsole
NET-Framework-Features NetFx4

Here's a full script to install IIS with common components on Windows 10:

$features = @(
    "IIS-WebServer",
    "IIS-WebServerRole",
    "IIS-CommonHttpFeatures",
    "IIS-HttpErrors",
    "IIS-HttpRedirect",
    "IIS-ApplicationDevelopment",
    "IIS-ManagementConsole"
)

foreach ($feature in $features) {
    Enable-WindowsOptionalFeature -Online -FeatureName $feature -NoRestart -All
}

Write-Output "IIS installation completed. System restart may be required."

Unlike the Server version, Windows 10 won't automatically install dependencies. You'll need to:

# First enable the container feature
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart

# Then enable nested virtualization if needed
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor -All -NoRestart

To check installed features in Windows 10:

Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq "Enabled"}
  • Test feature names using Get-WindowsOptionalFeature -Online first
  • Add error handling for cases where features aren't available
  • Consider using DISM commands as an alternative for some scenarios
  • Document the Windows 10 specific requirements in your scripts

For scripts that need to work on both Server and Client OS:

if ((Get-CimInstance Win32_OperatingSystem).ProductType -eq 1) {
    # Windows 10/11 client version
    Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer -NoRestart
} else {
    # Windows Server version
    Install-WindowsFeature -Name Web-Server -IncludeManagementTools
}