Created
November 7, 2019 14:40
-
-
Save jeroenmaes/c3dd9cd554bd7e14e78ed6da0b9268fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://www.saotn.org/iis-application-pool-recycle-on-specific-times-not-regular-time-interval/ | |
Import-Module WebAdministration | |
$appPools = Get-ChildItem IIS:\apppools | where {$_.Name -match "APP1|APP2"} | |
$timeDiff = 0 | |
$appPools | ForEach-Object { | |
$pool = $("IIS:\AppPools\") + ($_.Name) | |
#Disable Periodic Recycle | |
set-ItemProperty $pool -Name Recycling.periodicRestart.time -Value 0.00:00:00 | |
#Set Fixed Interval Recycle | |
$time = (get-date 01:00:00).AddMinutes($timeDiff).ToString("HH:mm:ss") | |
clear-ItemProperty $pool -Name Recycling.periodicRestart.schedule | |
set-ItemProperty $pool -Name Recycling.periodicRestart.schedule -Value @{value=$time} | |
Write-Host $pool - $time | |
#Increment interval | |
$timeDiff+=5 | |
#Use sleep because the change of the setting triggers a recycle... | |
Start-Sleep -s 30 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment