Skip to content

Instantly share code, notes, and snippets.



Last active Mar 18, 2019
What would you like to do?
IIS Background Worker Setting
## IIS WebAdmin Module
Import-Module WebAdministration
$AppPoolInstance = Get-Item IIS:\AppPools\$AppPool
Write-Output "Set Site PreLoadEnabled to true"
Set-ItemProperty IIS:\Sites\$Site -name applicationDefaults.preloadEnabled -value True
Write-Output "Set Recycling.periodicRestart.time = 0"
$AppPoolInstance.Recycling.periodicRestart.time = [TimeSpan]::Parse("0");
$AppPoolInstance | Set-Item
Write-Output "Set App Pool start up mode to AlwaysRunning"
$AppPoolInstance.startMode = "alwaysrunning"
Write-Output "Disable App Pool Idle Timeout"
$AppPoolInstance.processModel.idleTimeout = [TimeSpan]::FromMinutes(0)
$AppPoolInstance | Set-Item
if ($appPoolStatus -ne "Started") {
Write-Output "Starting App Pool"
Start-WebAppPool $AppPool
} else {
Write-Output "Restarting App Pool"
Restart-WebAppPool $AppPool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment