Skip to content

Instantly share code, notes, and snippets.

@csdy
Created September 5, 2022 12:49
Show Gist options
  • Save csdy/e3c411a08645191ea5329f00357a3421 to your computer and use it in GitHub Desktop.
Save csdy/e3c411a08645191ea5329f00357a3421 to your computer and use it in GitHub Desktop.
IIS Administration Cheat Sheet

IIS Manager

The IIS Manager application can be started with with following command:

inetmgr.exe

Optionally, the file extension can be omitted:

inetmgr

PowerShell

Start IIS Service

Start-Service w3svc

Stop IIS Service

Stop-Service w3svc

Restart IIS Service

Restart-Service w3svc

IISAdministration Module

The following commands require the IISAdministration module to be installed. To install the module, open a new PowerShell window as Administrator and execute the following command:

Install-Module -Name 'IISAdministration'

To see the available cmdlets available with this module, enter the following command:

Get-Command -Module 'IISAdministration'

...COMING SOON...

Command Prompt

Start IIS Service

net start w3svc

Stop IIS Service

net stop w3svc

IISReset

Start IIS Service

iisreset /start

Stop IIS Service

iisreset /stop

Restart IIS Service

iisreset /restart

Show IIS Service Status

iisreset /status

APPCMD

Pre-Requisites

APPCMD must be installed before it can be used. Follow the steps below to enable this feature.

  1. Open a command prompt as Administrator
  2. Enter the following command:
optionalfeatures
  1. Navigate to Internet Information Services > Web Management Tools
  2. Enable IIS Management Scripts and Tools
  3. Click OK
  4. Wait for installation to complete
  5. Open a new PowerShell windows as Administrator
  6. Enter the following command
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\Windows\System32\inetsrv", [EnvironmentVariableTarget]::Machine)
  1. Close all Command and Powershell windows

Objects

List All Sites

appcmd list sites

List Stopped Sites

appcmd list sites /state:Stopped

List Site not Configured to AutoStart

appcmd list /serverAutoStart:false

List Worker Processes

appcmd list wps

List Worker Processes for Specific AppPool

appcmd list wps /apppool.name:DefaultAppPool

List Current Requests

appcmd list requests

List Current Requests for Specific AppPool

appcmd list requests /apppool.name:DefaultAppPool

Backups

Each time a configuration change is made within IIS, a backup of the configuration is saved to the following location:

%SystemDrive%\inetpub\history

Manually created backups are stored in the following location:

%SystemDrive%\inetpub\backups

Backups can be restored from either location.

The following commands can be used to create and restore backups via the APPCMD utility.

Create Backup

appcmd add backup

Create Backup with Custom Name

appcmd add backup MyBackup

List Available Backups

appcmd list backups

Restore Backup

appcmd restore backup "MyBackup"

Sites/Applications

List Sites

appcmd list sites

Show Site Information

appcmd list site "Default Web Site" /text:*

List Site Applications

appcmd list apps /site.name:"Default Web Site"

Create Site

appcmd add site /name:MyNewSite /bindings:"http/mynewsite.com:80:" /physicalPath:"C:\home\MyNewSite\"

Delete Site

appcmd delete site "MyNewSite"

Add AppPool to Site

appcmd set app "MySite/" /applicationPool:MyAppPool

Virtual Directories

List Virtual Directories

appcmd list vdirs

List Virtual Directories for Site

appcmd list vdirs /app.name:"Default Web Site/"

Create Virtual Directory

appcmd add vdir /app.name:"MySite/app1" /path:/vdir1 /physicalPath:"C:\home\vdirpath"

Application Pools

List AppPools

appcmd list apppools

List Started AppPools

appcmd list apppools /state:started

Show AppPool State

appcmd list apppools "MyAppPool"

List AppPool Details

appcmd list apppool "MyAppPool" /text:*

Create AppPool

appcmd add apppool /name:MyAppPool

Add Site to AppPool

appcmd set app "MySite/" /applicationPool:MyAppPool

Start AppPool

appcmd start apppool "MyAppPool"

Stop AppPool

appcmd stop apppool "MyAppPool"

Change AppPool Property

appcmd set apppool "MyAppPool" /managedRuntimeVersion:v4.0

Changes AppPool Property (Nested)

appcmd set apppool "MyAppPool" /processModel.pingingEnabled:false

Configuration

List Site Configuration

appcmd list config "Default Web Site/"

List Configuration Section

appcmd list config "Default Web Site/" /section:httpErrors

Set Configuration Property

appcmd set config "Default Web Site/" /section:httpErrors /errorMode:Detailed

List Configuration Locations

appcmd search config "Default Web Site/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment