Quantcast
Viewing latest article 7
Browse Latest Browse All 3454

IIS App Pool Status with Powershell

I realize AppInsight can do this out of the box, but for various reasons AppInsight isn't an option. I'm trying to get the status of an application pool and display it using a Powershell monitor, but having an issue with getting it to work right;

 

import-module WebAdministration

$results = Get-ChildItem IIS:\AppPools\* | Where-Object { $_.Name -like "www.mysite.com*" }

 

foreach ($item in $results) {

 

$appPool = $item.Name

$status = $item.State

 

write-host "Message:$appPool"

write-host "Statistic.:$status"

 

 

}

 

The above only lists the first result, and shows Statistic as "NaN".  If I remove the Statistic line, it outputs all of the results, but reports "get output failed".

 

What am I missing here?


Viewing latest article 7
Browse Latest Browse All 3454

Trending Articles