Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Last active June 15, 2023 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ankitvijay/9dd0aef6450a30d34516e0642d5e30b5 to your computer and use it in GitHub Desktop.
Save ankitvijay/9dd0aef6450a30d34516e0642d5e30b5 to your computer and use it in GitHub Desktop.
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