列出 IIS6 场中所有已停止的应用程序池
我只想打印那些已停止或停止的 IIS6 池(AppPoolState 为 3 或 4)。如果其他一切都很好(全部启动),只需打印“OK”。我不确定是否有一种简单的方法来检查所有这些。我尝试循环遍历应用程序池,逐一检查每个状态,但它看起来有点复杂,似乎有一种更简单的方法可以做到这一点。
这段代码将进入一个循环,该循环遍历大量服务器,对每个服务器运行其他检查,然后打印出一个表。
$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
}
I'd like to print only those IIS6 pools that 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
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以检查集合中是否有任何项目,如下所示:
You can check if there are any items in a collection like this: