开发者

List all stopped application pools in an IIS6 farm

I'd like to print only those IIS6 pools t开发者_如何学Pythonhat are stopped or stopping (have an AppPoolState of 3 or 4). If everything else is fine (all started), just print out "OK". I'm not sure for a simple way to check all of them. I've tried to loop through app pools checking each state one by one, but it looks a bit complicated and there seems to be an easier way to do this.

This code will go inside a loop that runs through a huge list of servers running other checks on each then prints out a table.

$iispools = [ADSI]"IIS://$server/W3SVC/AppPools" | foreach {$_.children} | select Name,AppPoolState | where {($_.name -ne "DefaultAppPool")}

if (condition?)
{
    write-host "OK"
}
else {
    # print stopped/stopping pools here
    $iispools | where { $_.apppoolstate -ge 3 } | convertto-html -fragment
}


You can check if there are any items in a collection like this:

$stoppedPools = $iispools | where { $_.apppoolstate -ge 3 }
if (!$stoppedPools)
{
    write-host "OK"
}
else 
{
    # print stopped/stopping pools here
    $stoppedPools | convertto-html -fragment
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜