Automating Web Server Deployment
Internet Information Services (IIS) is Microsoft’s robust, enterprise-grade web server, heavily used to host ASP.NET applications, corporate intranet portals, and basic static websites. While you can install IIS by opening Server Manager and clicking through a dozen pages in the “Add Roles and Features” wizard, doing so is tedious and prone to human error—especially if you are trying to build an identical cluster of five load-balanced servers.
Instead, you can install the IIS role and all its required sub-features in a matter of seconds using a single PowerShell cmdlet: Install-WindowsFeature.
Step 1: The Basic Installation
To install the default IIS web server role, open an elevated PowerShell prompt (Run as Administrator) and execute the following command:
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
-Name Web-Server: The exact system name for the IIS role.-IncludeManagementTools: This is critical. Without this flag, Windows will install the web engine, but it will not install the graphical IIS Manager console (inetmgr.exe), leaving you unable to manage the server easily.
Step 2: Installing Additional Application Features
The basic command above installs a very lightweight version of IIS designed only to serve static HTML files. If you are hosting a modern web application, you will likely need support for ASP.NET, WebSocket protocols, or Basic Authentication.
You can install multiple features simultaneously by providing a comma-separated list of their specific names:
Install-WindowsFeature -Name Web-Server, Web-Asp-Net45, Web-WebSockets, Web-Basic-Auth -IncludeManagementTools
Step 3: Verify the Installation
The installation usually takes less than a minute. PowerShell will display a progress bar, and when finished, it will output a small table showing the Success status and whether a system Restart Needed is required (IIS usually does not require a reboot).
To verify the server is actively hosting web traffic, you don’t even need to open a web browser. You can use PowerShell’s Invoke-WebRequest to ping the local host:
(Invoke-WebRequest -Uri "http://localhost").StatusCode
If the command returns 200, your IIS server is successfully running and returning the default welcome page.
How to Remove IIS
If you are decommissioning the server or moving the web application to a different machine, you can quickly strip the IIS role from the operating system to reclaim resources and reduce your security attack surface.
Uninstall-WindowsFeature -Name Web-Server -IncludeManagementTools -Remove
The -Remove flag goes a step further than uninstalling; it completely deletes the IIS installation binaries from the server’s hard drive (the WinSxS folder), freeing up valuable disk space.