Skip to content

How to Create an IIS Website and Application Pool with PowerShell Print

  • 0

How to Create an IIS Website and Application Pool with PowerShell

Applies to: Windows Server 2019, 2022 and 2025.

A dedicated application pool isolates worker-process settings and identity. Each site needs a unique binding combination.

Web-server changes can expose data or interrupt production traffic. Use backups, least privilege and a staged validation path. Visit networkmanager.info for managed Windows VPS services.

Prerequisites

  • Create content directory and permissions.
  • Choose hostname and ports.
  • Define application pool runtime.
  • Create DNS after local testing.

Procedure

Step 1: Load WebAdministration

Open elevated PowerShell.

Import-Module WebAdministration

Step 2: Create content

Add a simple controlled file.

New-Item -ItemType Directory -Path 'D:\Web\Portal' -Force
Set-Content -Path 'D:\Web\Portal\index.html' -Value '<h1>Portal ready</h1>'

Step 3: Create pool

Use No Managed Code for a static site.

New-WebAppPool -Name 'PortalPool'
Set-ItemProperty IIS:\AppPools\PortalPool -Name managedRuntimeVersion -Value ''

Step 4: Create site

Bind hostname on an unused port.

New-Website -Name 'Portal' -PhysicalPath 'D:\Web\Portal' -ApplicationPool 'PortalPool' -Port 80 -HostHeader 'portal.corp.example'

Step 5: Set permissions

Grant read/execute to the application-pool identity as required.

Verification

Check site, pool, binding and local Host-header response.

Get-Website -Name Portal
Get-WebAppPoolState -Name PortalPool
Invoke-WebRequest http://localhost -Headers @{Host='portal.corp.example'} -UseBasicParsing

Rollback

Stop and Remove-Website, then Remove-WebAppPool after confirming no application uses them. Preserve content separately.

Security notes

A Host-header binding does not create DNS; publish the record only after the site passes local tests.

Official references

Explore Netcloud24 Canada.


Was this answer helpful?

« Back