Fork me on GitHub

While IIS 7 comes with integrated Powershell cmdlets, the still widely used IIS 6 doesn't.
Here are some IIS 6 cmdlets to automated most of the usual tasks of setting up websites.

Application pools

Start-IIS6AppPool

Description

Starts the specified application pool.

Parameters

Name Type Required Description Example
Name string Name of the app pool to start MyPool

Code sample

Start-IIS6AppPool -Name "MyPool"

Stop-IIS6AppPool

Description

Stops the specified application pool.

Parameters

Name Type Required Description Example
Name string Name of the app pool to stop MyPool

Code sample

Stop-IIS6AppPool -Name "MyPool"

New-IIS6AppPool

Description

Creates an application pool.

Parameters

Name Type Required Description Example
Name string Name of the app pool to create MyPool
Username string Identity of the app pool PoolUser
Password string Corresponding password if the user is set Password1

Code sample

New-IIS6AppPool -Name "MyPool" -Username "Bob" -Password "Password1"

Remove-IIS6AppPool

Description

Deletes an application pool.
Note: the application pool has to be empty to be deleted.

Parameters

Name Type Required Description Example
Name string Name of the app pool to delete MyPool

Code sample

Remove-IIS6AppPool -Name "MyPool"

Websites

Start-IIS6Website

Description

Starts an existing website.

Parameters

Name Type Required Description Example
Name string Name of the website to start MySite

Code sample

Start-IIS6Website -Name "MySite"

Stop-IIS6Website

Description

Stops an existing website.

Parameters

Name Type Required Description Example
Name string Name of the website to stop MySite

Code sample

Stop-IIS6Website -Name "MySite"

New-IIS6Website

Description

Creates a new website.

Parameters

Name Type Required Description Example
Name string Name of the website to create MySite
Path string Path to the website root on disk C:\Inetpub\MySite
AppPool string Name of the app pool that will host the website MyPool
Ip string Ip address binding 162.10.16.4
Port integer Port number to use 1234
HostHeader string Host header to use my.website.com
DefaultAccess switch Enables anonymous access to the website
DefaultDoc string List of default documents Default.aspx

Code sample

New-IIS6Website -Name "MySite" -Path "C:\Inetpub\MySite" -AppPool "MyPool"
-Ip "162.10.16.4" -Port 1234 -HostHeader "my.website.com" -DefaultAccess -DefaultDoc "Default.aspx"

Remove-IIS6Website

Description

Deletes an existing website.

Parameters

Name Type Required Description Example
Name string Name of the website to delete MySite

Code sample

Remove-IIS6Website -Name "MySite"

Virtual directories

New-IIS6VirtualDirectory

Description

Creates a new virtual directory inside a given website.

Parameters

Name Type Required Description Example
Website string Name of the website that will contain the virtual directory MySite
Name string Virtual directory name Content
Path string Path the directory should point to C:\Inetpub\Content

Code sample

New-IIS6VirtualDirectory -Website "MySite" -Name "Content" -Path "C:\Inetpub\Content"

Remove-IIS6VirtualDirectory

Description

Deletes an existing virtual directory from a website.

Parameters

Name Type Required Description Example
Website string Name of the website that contains the virtual directory MySite
Name string Name of the virtual directory to delete Content

Code sample

Remove-IIS6VirtualDirectory -Website "MySite" -Name "Content"