in C#/Powershell - Is it possible to change the Idle TimeOut for an IIS Application Pool?

If you are using PowerShell 2 or later, you should have access to Set-ItemProperty. You'll also want to load the WebAdministration module.

You can then do (example taken from here)

Set-ItemProperty ("IIS:\AppPools\$name") -Name processModel.idleTimeout -value ( [TimeSpan]::FromMinutes(0))

and verify that the value was changed with

Get-ItemProperty ("IIS:\AppPools\$name") -Name processModel.idleTimeout.value

@R0MANARMY's answer (currently the most popular) didn't work for me. It runs fine, but the subsequent check shows that the idle timeout is unchanged.

Based on this blog post, that answer modifies an in-memory copy of the object. I modified the sample code in R0MANARMY's answer as:

Get-ChildItem IIS:\AppPools\$name | ForEach { $_.processModel.IdleTimeout = [TimeSpan]::FromMinutes(0); $_ | Set-Item; }

%windir%\system32\inetsrv\appcmd set config -section:applicationPools
   -applicationPoolDefaults.processModel.idleTimeout:00:00:00

Tags:

C#

Iis

Powershell