North East Bytes - a Microsoft technology usergroup in North East England.

Powered by Squarespace

« Locating AD Computer Objects with PowerShell | Main | NEBytes October event - Andrew Fryer on SQL Server "Denali" »

Finding IIS Application Pool States with PowerShell

Last night an attendee at NEBytes asked me how he can see the state of an application pool in IIS using PowerShell. I'm using IIS 7.5, but the first method is the way to do it in IIS 7.0 too...

Using the PowerShell provider you can browse through the components of IIS like you would the filesystem - it's presented like a drive*, so you can do dir iis: to see the top level containers. To work with application pools, you can move into their container with cd iis:\AppPools after which a dir will list the app pools along with their states. For each of the application pools you'll seeing a little bit of information as defined by the default formatting. You can see all the details of the first one with by piping to a formatting cmdlet, for example dir | Format-List *

That will give you the properties of the application pool, but not what you can do with it. Piping instead to Get-Member will tell you not only the properties of the object, but also the methods that it exposes, like start/stop/recycle.

New in IIS 7.5's webadministration module for PowerShell are a set of cmdlets for working with IIS, including application pools. The cmdlet that answers the original question is Get-WebAppPoolState, and there are cmdlets for starting, stopping and recycling which are Start-WebAppPool, Stop-WebAppPool and Restart-WebAppPool (not recycle because PowerShell has a restriction on verbs in cmdlet names).

Those aren't especially hard to remember, but if you wanted to know all of the cmdlets that relate to IIS application pools, you can do Get-Command *apppool*, or to see all of the commands in the webadministration module, Get-Command -PSSnapin  webadministration.

* Type Get-PSDrive to see what else has been presented in this way by the providers installed on your system.

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    The process of writing and reading is very essential and significant. The production is achieved with the respect to the knowledge and material. The facets of the life are learned and comprehended.’

Reader Comments (2)

Thanks, good article. To enable these features, I had to run...

PS C:\>Import-Module WebAdministration

April 4, 2013 | Unregistered CommenterSteve C

not mycredit, found @

function ConvertTo-AppPoolState($value)
1 {"Starting"}
2 {"Started"}
3 {"Stopping"}
4 {"Stopped"}
default {"Unknown"}

$iis = "IISServerName"

# PowerShell v1
$AppPools = [ADSI]"IIS://$iis/W3SVC/AppPools"
$AppPools.psbase.Children | Select-Object @{n='Name';e={$_.psbase.Name}},@{n='AppPoolState';e={ConvertTo-AppPoolState $_.AppPoolState.Value}}

# PowerShell v2
$AppPools = [ADSI]"IIS://$iis/W3SVC/AppPools"
$AppPools.Children | Select-Object Name,@{n='AppPoolState';e={ConvertTo-AppPoolState $_.AppPoolState.Value}}

November 1, 2013 | Unregistered CommenterNnuxX

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>