Search This Blog

Thursday, June 16, 2016

Powershell: IIS: Set application pool idle-timeout and application pool recycle time.

Most of my IIS scripts will be setting the IIS config options in the applicationhost.config file. This is a personal preference, it puts all config in one central location and prevents the web.config files potentially being modified and deleted in code deployments.

Add-PSSnapin WebAdministration -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
#<name> is the application pool name
--Set the idle time to 0(off)
Set-ItemProperty ("IIS:\AppPools\<name>") -Name processModel.idleTimeout -value ( [TimeSpan]::FromMinutes(0))
--disable the regular time of 1740 minutes
Set-ItemProperty ("IIS:\AppPools\<name>") -Name Recycling.periodicRestart.time -Value "00:00:00"
--Clear any scheduled restart times
Clear-ItemProperty ("IIS:\AppPools\<name>") -Name Recycling.periodicRestart.schedule
--Set scheduled restart times
Set-ItemProperty ("IIS:\AppPools\<name>") -Name Recycling.periodicRestart.schedule -value @{value="05:00:00"}


1 comment:

  1. Nice. You included the one thing I was having trouble figuring out - disable the regular time of 1740 minutes. I missed the ".time". Cheers!