Hello,
I'm try to create a powershell script for monitoring status of all application pools on my server, and if one is stopped, restart it.
The script is simple, but I try to stop one application pool (in IIS Manager this pool is stopped), but the script he sees it as started, no stopped :|
Can you help me ?
Import-Module WebAdministration
IIS:
Set-Location AppPools
$ApplicationPools = dir
foreach ($item in $ApplicationPools)
{
$ApplicationPoolName = $item.Name
$ApplicationPoolStatus = Get-WebAppPoolState $ApplicationPoolName
$ApplicationPoolStatusValue = $ApplicationPoolStatus.Value
#Write-Host "$ApplicationPoolName -> $ApplicationPoolStatusValue"
if($ApplicationPoolStatus.Value -ne "Started")
{
Write-Host "-----> $ApplicationPoolName found stopped."
Start-WebAppPool -Name $ApplicationPoolName
Write-Host "-----> $ApplicationPoolName started."
}
}