Skip to content

How to Install IIS Web Server with PowerShell Print

  • 0

Applies to: Windows Server 2019, Windows Server 2022 and Windows Server 2025, subject to the workload and edition requirements below.

Install a web platform with only the required modules

Internet Information Services hosts websites and applications through a modular Windows Server role. The base role can serve static content, while application frameworks and authentication methods need their own components. Installing every role service increases the configuration and maintenance surface and still may not supply a modern application’s required runtime. Start from the application’s hosting requirements and build the smallest supported feature set.

This guide installs IIS with administration tools and verifies a controlled static HTTP response. It does not publish a production application or assume that port 80 should be open to every network. Domain membership is a requirement for some integrated-authentication designs, but it is not a universal prerequisite for IIS itself. Public, workgroup and domain-member web servers require different identity and management choices.

Prepare identity, storage and network scope

Choose a supported, patched Windows Server and confirm the application vendor supports its release. Windows Server 2019, 2022 and 2025 all provide IIS 10, but the same major IIS version does not mean identical operating-system TLS capabilities or feature defaults. Record the actual server build and installed modules when diagnosing compatibility.

Plan content, application data and log locations separately. The worker process normally needs read access to application code and only narrowly scoped write access to designated data folders. Keep deployment credentials separate from runtime identity. Decide which network may reach the initial test listener, which DNS name production will use and how the HTTPS certificate will be issued and renewed.

Use elevated Windows PowerShell 5.1 for the built-in WebAdministration workflow in this series. Confirm whether the server is already hosting sites or has a process listening on the intended port. A role installation on an existing shared server is a change to every workload on that machine, not an isolated application deployment.

Get-ComputerInfo | Select-Object CsName,WindowsProductName,OsBuildNumber
Get-WindowsFeature Web-*
Get-NetTCPConnection -State Listen -LocalPort 80 -ErrorAction SilentlyContinue

Install IIS and management components

Install the Web-Server role with management tools and inspect the returned result. This selects the role’s default components; it does not add every optional application or authentication feature. Review the resulting feature inventory rather than assuming a short command means a minimal custom feature profile.

$result = Install-WindowsFeature -Name Web-Server -IncludeManagementTools
$result | Format-List Success,RestartNeeded,ExitCode,FeatureResult
Get-WindowsFeature Web-* | Where-Object Installed
Get-Service W3SVC,WAS

WAS manages activation and process-related functions, while W3SVC participates in HTTP web publishing. Their running state is useful installation evidence but does not prove a site or application works. If a restart is required, perform it in the agreed window and repeat the feature and service checks. On Server Core, use PowerShell or approved remote IIS administration rather than expecting the local graphical management console.

Add framework features only when the application needs them

For a classic ASP.NET Framework application, the required IIS role services may include ASP.NET 4.x and its associated .NET extensibility and ISAPI components. For ASP.NET Core, the Windows Server ASP.NET role service is not a substitute for the supported .NET Hosting Bundle and its ASP.NET Core Module. Install the runtime and hosting components in the order and version documented for the application.

A PHP or other FastCGI application has a different runtime and handler configuration. Windows Authentication, Basic Authentication, WebSockets, CGI and management delegation should be added only for identified requirements. Do not enable directory browsing or legacy IIS compatibility merely to make a first request succeed. Preserve request filtering and choose authentication intentionally.

# Inspect options before adding an application-specific feature:
Get-WindowsFeature Web-Asp-Net45,Web-Net-Ext45,Web-CGI,Web-Windows-Auth,Web-WebSockets
Import-Module WebAdministration
Get-WebGlobalModule | Select-Object Name,Image

Application runtimes have their own support lifecycles and updates. Record them alongside Windows features so a later administrator does not assume that a fully patched OS also means the application framework is current.

Inspect the default site before exposing traffic

A normal IIS role installation can create Default Web Site and its initial content. Review its bindings and physical path. A wildcard HTTP binding can accept traffic on multiple server addresses if firewall and upstream policy permit it. Do not leave a sample site exposed merely because it is useful for installation verification.

Get-Website | Select-Object Name,State,PhysicalPath,Bindings
Get-WebBinding
Get-WebAppPoolState -Name 'DefaultAppPool'
Invoke-WebRequest -Uri 'http://localhost/' -UseBasicParsing

An expected local HTTP response shows that the listener and default content path are working. Record the status code and returned content rather than treating any response as correct. A 403.14 response may mean no default document and directory browsing disabled; it does not justify enabling directory browsing on an application tree. A 503 can indicate a stopped or failing application pool. Inspect the relevant layer before changing security settings.

Verify the intended remote path and logging

If remote HTTP testing is part of the approved staging plan, permit only the necessary source network through the applicable firewall policy and test from that network. Test-NetConnection to port 80 establishes transport; an HTTP request establishes the selected site and response. Use the intended hostname when host-header bindings are involved.

Locate the site ID and logging configuration. IIS request logs commonly reside under the configured log directory in a W3SVC site-ID subfolder, but verify the actual path. Check status, substatus and Win32 status for a test request. Log records can appear after buffering rather than instantly. Include HTTP.sys error logs and relevant Windows events when a request fails before normal site logging.

Get-Website | Select-Object Name,Id,PhysicalPath,State
Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' `
  -Filter 'system.applicationHost/sites/siteDefaults/logFile' -Name 'directory'
Test-NetConnection -ComputerName 'web01.corp.example' -Port 80

Keep logs on monitored storage with appropriate retention and access. Unbounded logs on the operating-system volume can turn a successful web deployment into a later capacity outage.

Diagnose installation and first-request errors

If feature installation fails, inspect Server Manager and servicing evidence and verify any feature payload source matches the Windows release. If W3SVC or WAS cannot start, inspect System events and configuration validity. If port 80 is already in use, identify the owning listener and HTTP.sys registrations before stopping a process. Another application may legitimately own the port.

For 500.19 errors, capture the configuration error, file and line and check module availability, locked sections and malformed configuration. For permission errors, identify the actual runtime and anonymous-authentication identities rather than granting Everyone write access. For framework startup failures, inspect the application’s hosting module and event evidence. Enabling more IIS features at random can hide the missing prerequisite while adding unrelated exposure.

Rollback and complete production preparation

If this is a new installation with no dependent sites, remove the test exposure and uninstall only the introduced role services through a planned rollback. On an established server, do not remove Web-Server while other applications depend on it. Preserve IIS configuration, content, certificates, runtime versions and logs before any removal. Feature uninstallation is not a complete backup or migration method.

Before production, create a dedicated site and application pool, configure HTTPS with a valid certificate, review authentication and file permissions, set monitoring and application-aware backups, and remove or stop unused sample content. Validate the real application with its owner. A local IIS welcome page proves a useful installation milestone; production readiness requires a supported runtime, deliberate bindings and identity, observable errors and a recoverable deployment.

Related guidance and official references

Create a site and application pool; Bind an HTTPS certificate; Back up IIS configuration.


Was this answer helpful?

« Back