使用PowerShell设置AppPool空闲超时

时间:2012-10-11 18:20:46

标签: powershell iis-6 application-pool

如何使用powershell设置IIS6应用程序池的空闲超时?我在搜索中看到的只是如何设置应用程序池的回收时间并不完全相同。

这就是出现的情况,但我认为这不是我想要的:

$destinationPool.recycling.periodicRestart.schedule

2 个答案:

答案 0 :(得分:1)

我无法测试,但试试这个:

$ApplicationPool = Get-WmiObject -Class IISApplicationPoolSetting -Namespace "root/microsoftiisv2" | Where-Object {$_.Name -eq 'W3SVC/APPPOOLS/DefaultAppPool'}
$ApplicationPool.IdleTimeout=0
$ApplicationPool.Put()

答案 1 :(得分:1)

使用DSC(所需状态配置)

cAppPool $application.AppPool.Name 
{ 
    Name                    = $application.AppPool.Name                 
    AutoStart               = $application.AppPool.AutoStart            
    StartMode               = $application.AppPool.StartMode            
    ManagedRuntimeVersion   = $application.AppPool.ManagedRuntimeVersion
    ManagedPipelineMode     = $application.AppPool.ManagedPipelineMode  
    IdentityType            = $application.AppPool.IdentityType  
    LoadUserProfile         = $application.AppPool.LoadUserProfile
    Ensure                  = "Present" 
    idleTimeout             = "00:00:00"
}

idleTimeoutstring而不是int类型的事实让我感到困惑了一段时间。尝试静默使用"0"会使其默认为20分钟

(见cAppPool on GitHub