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

前端 未结 8 519
别那么骄傲
别那么骄傲 2021-02-05 08:29

I want to disable the idle timeout (Set it to Zero) of an application pool and I want to perform this at setup time, is it possible to perform this action from C# or PowerShell?

8条回答
  •  后悔当初
    2021-02-05 09:05

    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
    

提交回复
热议问题