IIS (Internet Information Services) is Windows Server’s web server. Many internal business apps run on it, so knowing IIS basics is part of almost every Windows admin role.
Lab:
Install-WindowsFeature Web-Server -IncludeManagementToolson a test server, then openhttp://localhost– you’ll see the IIS welcome page.
The four pieces
| Piece | What it is |
|---|---|
| Site | A website with a name, a folder (physical path) and one or more bindings |
| Binding | How the site is reached: protocol + IP + port + host name, e.g. https *:443 app.contoso.local |
| Application | A sub-folder of a site that runs as its own app, e.g. /api |
| Application pool | The worker process (w3wp.exe) that runs one or more apps, with its own identity and settings |
App pools isolate apps from each other: if one crashes or leaks memory, the others keep running. Give important apps their own pool.
Create a site with PowerShell
Import-Module WebAdministration # or IISAdministration on newer servers
New-Item -ItemType Directory -Path D:\Sites\DemoApp -Force
Set-Content D:\Sites\DemoApp\index.html '<h1>Demo app works</h1>'
New-WebAppPool -Name DemoAppPool
New-Website -Name DemoApp -PhysicalPath D:\Sites\DemoApp -ApplicationPool DemoAppPool `
-Port 80 -HostHeader demo.contoso.local
Add a DNS record for demo.contoso.local pointing to the server (or a hosts entry in your lab), then browse to it.
Keep site content on a data drive (like D:\Sites), not in C:\inetpub, so OS changes don’t touch it.
App pool settings that matter
- .NET CLR version – No Managed Code for static sites and .NET Core/.NET 5+ apps; v4.0 for classic ASP.NET.
- Identity – ApplicationPoolIdentity by default. If the app reads a network share or a database with Windows authentication, use a dedicated service account instead.
- Recycling – IIS restarts the worker process every 1740 minutes by default. Many teams change this to a fixed quiet time (e.g. 03:00) so users don’t notice.
- Rapid-Fail Protection – after 5 crashes in 5 minutes, IIS stops the pool. That’s what causes 503 Service Unavailable.
Get-WebAppPoolState -Name DemoAppPool
Restart-WebAppPool -Name DemoAppPool
Add HTTPS
- Get a certificate for the site name and import it into Local Computer → Personal (
certlm.msc). - IIS Manager → your site → Bindings → Add → type https, port 443, host name, choose the certificate.
- Tick Require Server Name Indication if several HTTPS sites share one IP.
New-WebBinding -Name DemoApp -Protocol https -Port 443 -HostHeader demo.contoso.local -SslFlags 1
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object Subject -like '*demo.contoso.local*'
(Get-WebBinding -Name DemoApp -Protocol https).AddSslCertificate($cert.Thumbprint, 'My')
Watch the certificate’s expiry date – an expired certificate is one of the most common avoidable outages.
Logs: where the answers are
IIS logs every request to C:\inetpub\logs\LogFiles\W3SVC<siteID>\ by default. Each line shows time (UTC), client IP, URL, status code, sub-status and time-taken (ms).
# Last 20 requests that returned a server error
Get-Content 'C:\inetpub\logs\LogFiles\W3SVC2\u_ex*.log' -Tail 2000 |
Where-Object { $_ -match ' 5\d\d ' } | Select-Object -Last 20
Logs grow forever unless you clean them up – schedule a task that deletes logs older than, say, 30 days.
Common errors
| Status | Usual cause | First check |
|---|---|---|
| 503 | App pool stopped (Rapid-Fail) or wrong identity password | App pool state; System event log (WAS events) |
| 500.19 | Bad web.config or a missing IIS module (e.g. URL Rewrite) |
The error page shows the config line |
| 500.30 / 502.5 | .NET Core app failed to start | Application event log; Hosting Bundle installed? |
| 401 | Authentication settings or permissions | Authentication feature; folder NTFS rights |
| 404 | Wrong physical path or missing file | Site path; does the file exist? |
FAQ
Is iisreset a good fix?
It restarts all of IIS and every site on the server. Prefer recycling the one app pool that has the problem.
Where do I find the site ID for the log folder?
IIS Manager → Sites shows an ID column, or run Get-Website | Select-Object Name, Id.
What’s next
Next: Patching Windows Server safely.
Practise this topic
Test yourself with free questions on this topic – instant answers and explanations.
Start practice questionsIISWindows ServerWeb ServerPowerShellTroubleshooting