Set-ItemProperty IIS:\ AppPools\[App_Pool] -Name Recycling.PeriodicRestart.Time在Server 2012 R2中无效

Jam*_*mes 5 powershell windows-server-2012-r2

我有几个服务器农场,一个有Server 2008 R2一个,有一个Server 2012 R2.经过一堆搜索,我发现以下powershell禁用默认的IIS应用程序池回收,我在管理PowerShell提示符下运行:

Set-ItemProperty IIS:\AppPools\Test -Name Recycling.PeriodicRestart.Time -Value 0
Run Code Online (Sandbox Code Playgroud)

这似乎工作正常(它在任何平台上都没有任何输出运行),但是当我随后尝试查询值时Server 2008 R2,我得到这个:

PSPath                      : WebAdministration::\\SERVER1\AppPools\Test
PSParentPath                : WebAdministration::\\SERVER1\AppPools
PSChildName                 : Test
PSDrive                     : IIS
PSProvider                  : WebAdministration
IsInheritedFromDefaultValue : False
IsProtected                 : False
Name                        : time
TypeName                    : System.TimeSpan
Schema                      : Microsoft.IIs.PowerShell.Framework.ConfigurationAttributeSchema
Value                       : 00:00:00
IsExtended                  : False
Run Code Online (Sandbox Code Playgroud)

但是Server 2012 R2,我明白了:

PSPath                      : WebAdministration::\\SERVER2\AppPools\Test
PSParentPath                : WebAdministration::\\SERVER2\AppPools
PSChildName                 : Test
PSDrive                     : IIS
PSProvider                  : WebAdministration
IsInheritedFromDefaultValue : True
IsProtected                 : False
Name                        : time
TypeName                    : System.TimeSpan
Schema                      : Microsoft.IIs.PowerShell.Framework.ConfigurationAttributeSchema
Value                       : 1.05:00:00
IsExtended                  : False
Run Code Online (Sandbox Code Playgroud)

请注意,Value在第一个示例中00:00:00,但在第二个示例中是1.05:00:00.这是继承自的默认值DefaultAppPool.

我也试图改变它的值DefaultAppPool,但我得到了相同的结果 - 它可以工作2008 R2但不能工作2012 R2,所以我很确定继承不是问题.

有一些替代的方式来做到这一点Server 2012 R2,以便它不忽略命令或更好的-一个办法做到这一点,在这两个工程Server 2008 R2Server 2012 R2

Jam*_*mes 6

啊.经过很多挫折之后,它似乎Set-ItemProperty区分大小写的,即使Get-ItemProperty不是.对于所有发现这一点的人来说,解决方案非常简单:

Set-ItemProperty -Path "IIS:\AppPools\Test" -Name recycling.periodicRestart.time -Value 00:00:00
Run Code Online (Sandbox Code Playgroud)

(注意属性名称的下限).为了增加对伤害的侮辱Server 2012 R2,Set-ItemProperty在案件中无声地失败(没有双关语),其中属性名称框与底层C:\Windows\System32\inetsrv\config\applicationHost.config文件中的正确XML元素名称不完全匹配.