Do you have a need for IIS in your Windows 11 development station? And now you need to install IIS? Internet Information Services (IIS) for Windows Server is a flexible, secure and manageable webserver for hosting anything on the web. Here I describe how you can easily install IIS and some modules using PowerShell.

In this post I show you how you can install IIS in your Windows 11 DevOps workstation, easily using PowerShell and ready for automation.

Steps to install Internet Information Services (IIS) in Windows 11 using PowerShell

To install IIS in Windows 11 you need PowerShell and some of its cmdlets. The PowerShell cmdlets you will be using are:

  • Get-WindowsOptionalFeature
  • Enable-WindowsOptionalFeature

First, lookup the available IIS related features:

Get-WindowsOptionalFeature -Online | Where-Object FeatureName -like 'IIS-*'

This lists a long list of available Windows optional features and their (installation) state. Some interesting ones are:

Yes, these are a lot of features (e.g IIS modules). My take in this is you may want to represent an actual (general) Windows Server IIS webhosting server in your local development environment. I added some links to interesting articles to showcase why a module is important or interesting.

If you want to manage websites in IIS (remote or local) you can install and setup IIS Manager for Remote Administration.

Windows Program and Features to turn IIS features on or off

Of course you can use Windows Program and Features to turn IIS features on or off, but as an DevOps engineer I'm sure you'll want to use PowerShell commands and cmdlets. Commands you can add to scripting to automate the roll-out of new IIS webservers.

Using PowerShell Enable-WindowsOptionalFeature to install IIS

Secondly, all we need to do next is to feed these features (IIS modules) to the Enable-WindowsOptionalFeature cmdlet. You can comma separate them on the command prompt, but for this, I like to create an array because that looks more clear and is more easy to extend in scripting. Plus it looks nice in diffs and commits ;-)

$features = @(  "IIS-WebServerRole",  "IIS-WebServer",  "IIS-CommonHttpFeatures",  "IIS-HttpErrors",  "IIS-HttpRedirect",  "IIS-ApplicationDevelopment",  "IIS-Security",  "IIS-RequestFiltering",  "IIS-NetFxExtensibility45",  "IIS-HealthAndDiagnostics",  "IIS-HttpLogging",  "IIS-RequestMonitor",  "IIS-HttpTracing",  "IIS-URLAuthorization",  "IIS-IPSecurity",  "IIS-Performance",  "IIS-HttpCompressionDynamic",  "IIS-WebServerManagementTools",  "IIS-IIS6ManagementCompatibility",  "IIS-Metabase",  "IIS-HostableWebCore",  "IIS-StaticContent",  "IIS-DefaultDocument",  "IIS-DirectoryBrowsing",  "IIS-WebDAV",  "IIS-WebSockets",  "IIS-ApplicationInit",  "IIS-ISAPIFilter",  "IIS-ISAPIExtensions",  "IIS-ASPNET45",  "IIS-ASP",  "IIS-CustomLogging",  "IIS-BasicAuthentication",  "IIS-HttpCompressionStatic",  "IIS-ManagementConsole",  "IIS-ManagementService",  "IIS-WindowsAuthentication")Foreach($feature in $features) {  Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName ${feature}}

Execute the above in an Admin Powershell command prompt. The -NoRestart parameter suppresses the constant requests for a reboot. Make sure to reboot once all features are installed and you have a fully fledged IIS webserver on your development station.

Don't forget to enable HSTS in IIS.

What additional features are available and how to add or remove one?

How to list all installed Windows Server Features using PowerShell Get-WindowsFeature and Get-WindowsOptionalFeature cmdlets.

To see all the features available related to IIS you can use:

Get-WindowsOptionalFeature -Online | Where-Object FeatureName -like 'IIS-*'

Further it's easy to figure out what is available, what is installed and what is not. Here's how:

Check for installed features

Get-WindowsOptionalFeature -Online | Where-Object { $_.State -eq "Enabled" } | Format-Table -Property featurename

PowerShell provides the means to list & verify installed Windows and Windows Server Features with the Get-WindowsFeature and Get-WindowsOptionalFeature cmdlets. Here is how to list all installed Windows Server features, sorted by name:

# list all INSTALLED Windows Server featuresGet-WindowsFeature `  | Where-Object { $_.Installed -eq "True" } `  | Format-Table DisplayName, Installed
Get-WindowsFeature `  | Where-Object { $_.Installed -eq "True" } `  | Format-Table Name, Installed

Get-WindowsFeature relies on the ServerManager module. If you don't have Server Manager available, then you can use Get-WindowsOptionalFeature in Windows 11 / 10:

Get-WindowsOptionalFeature -Online `  | Where-Object { $_.State -eq "Enabled" } `  | Format-Table FeatureName, State

Check for available but not installed features

Get-WindowsOptionalFeature -Online | Where-Object { $_.State -eq "Disabled" } | Format-Table -Property featurename

Disable a Windows Feature

Disable-WindowsOptionalFeature -Online -FeatureName IIS-DirectoryBrowsing

Remove IIS from your computer

If you ever need to remove IIS you can use PowerShell as well. Don't forget to create an IIS backup first, and then remove IIS from Windows.

Donate a cup of coffee
Donate a cup of coffee

Thank you very much! <3 ❤️

4 Comments

Comments are closed