Automate IIS Setup and Features with Powershell

Recent versions of Windows and Windows Server let you install additional features through PowerShell. The IIS Web Server is not installed by default, but you can automate the process by using a Powershell script to install it.

Web Connection ships with a PowerShell script file Install-IIS_Features.ps1 which contains the commands to install IIS with the recommended features needed to run IIS for Web Connection.

.NET Version

Depending on the version of Windows you're running the .NET version may vary. On recent versions (10, 2012, 2016) the .NET version is .NET 4.5 (or later) which specified in NetFxExtensibility45 and ASPNET45. Older versions of Windows may use 40 instead of 45 for these so you may have to adjust the script accordingly.

Running Install-IIS-Features.ps1

The script is simply a bunch of Enable-WindowsOptionalFeature commands strung together to install the relevant IIS features.

To do this:

  • Open a PowerShell Command Prompt as Administrator
  • cd
  • Run: Install-IIS-Features.ps1

The commands will execute one after the other.

Script Content

For completeness sake here's the content of this file:

# Ensure you can run the scripts below
Set-ExecutionPolicy Bypass -Scope Process

Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools
Enable-WindowsOptionalFeature -Online -FeatureName IIS-IIS6ManagementCompatibility
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Metabase
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DirectoryBrowsing
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole

# Optional - but often useful in general for IIS usage
# Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets
# Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit


# List all features installed on Windows
# Get-WindowsOptionalFeature -Online | where {$_.state -eq "Enabled"} | ft -Property featurename

# List what features are available and not running
# Get-WindowsOptionalFeature -Online | where {$_.state -eq "Disable"} | ft -Property featurename

© West Wind Technologies, 1996-2018 • Updated: 11/10/18
Comment or report problem with topic