So here is a script to wake up a specific application pool, if that application pool is not “Started”
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function specificapppool { import-module WebAdministration $appPoolName="SharePoint - 80" if((Get-WebAppPoolState $appPoolName).Value -ne 'Started') { Start-WebAppPool -Name $appPoolName } } while ($true) { Start-Sleep -Seconds 10 specificapppool } |
and in case you want to check every application pool on the server (and start the ones that are not “started”):
Note: the script runs in loop too
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
function WakeupAppPool { Import-Module WebAdministration set-Location IIS:\AppPools $ApplicationPools = dir foreach ($item in $ApplicationPools) { $ApplicationPoolName = $item.Name $ApplicationPoolStatus = $item.state Write-Host "$ApplicationPoolName -> $ApplicationPoolStatus" if($ApplicationPoolStatus -ne "Started") { $timestamp = get-date -format "yyyyMMdd_hhmmtt" Write-Host "-----> $ApplicationPoolName found stopped." Start-WebAppPool -Name $ApplicationPoolName Write-Host "-----> $ApplicationPoolName started. at" $timestamp } } } while ($true) { Start-Sleep -Seconds 1800 wakeupAppPool } |
