Set-ItemProperty IIS:\AppPools\[App_Pool] -Name Recycling.PeriodicRestart.Time 在 Server 2012 R2 中无效
Set-ItemProperty IIS:\AppPools\[App_Pool] -Name Recycling.PeriodicRestart.Time has no effect in Server 2012 R2
我有几个服务器场,一个 Server 2008 R2
,一个 Server 2012 R2
。经过大量搜索,我发现以下 powershell 禁用默认的 IIS 应用程序池回收,我 运行 在管理 powershell 提示符下:
Set-ItemProperty IIS:\AppPools\Test -Name Recycling.PeriodicRestart.Time -Value 0
这似乎工作正常(它 运行 在任何一个平台上都没有任何输出),但是当我随后尝试在 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
但是在 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
请注意,第一个示例中的 Value
是 00:00:00
,但第二个示例中的 1.05:00:00
。这是从 DefaultAppPool
.
继承的默认值
我也尝试更改 DefaultAppPool
的值,但我得到了相同的结果——它适用于 2008 R2
但不适用于 2012 R2
,所以我'我相当确定继承不是问题。
在 Server 2012 R2
中是否有一些替代方法可以做到这一点,这样它就不会忽略命令或更好 - 一种在 Server 2008 R2
和 [=] 中都有效的方法16=]?
呃。经过多次挫折后,Set-ItemProperty
似乎是 case-sensitive,尽管 Get-ItemProperty
不是。对于所有发现此问题的人来说,解决方案非常简单:
Set-ItemProperty -Path "IIS:\AppPools\Test" -Name recycling.periodicRestart.time -Value 00:00:00
(注意 属性 名称的小写)。雪上加霜的是 Server 2012 R2
,Set-ItemProperty
在 属性 名称大小写与正确的 XML 元素名称不完全匹配的情况下静默失败(无双关语)在基础 C:\Windows\System32\inetsrv\config\applicationHost.config
文件中。
我有几个服务器场,一个 Server 2008 R2
,一个 Server 2012 R2
。经过大量搜索,我发现以下 powershell 禁用默认的 IIS 应用程序池回收,我 运行 在管理 powershell 提示符下:
Set-ItemProperty IIS:\AppPools\Test -Name Recycling.PeriodicRestart.Time -Value 0
这似乎工作正常(它 运行 在任何一个平台上都没有任何输出),但是当我随后尝试在 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
但是在 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
请注意,第一个示例中的 Value
是 00:00:00
,但第二个示例中的 1.05:00:00
。这是从 DefaultAppPool
.
我也尝试更改 DefaultAppPool
的值,但我得到了相同的结果——它适用于 2008 R2
但不适用于 2012 R2
,所以我'我相当确定继承不是问题。
在 Server 2012 R2
中是否有一些替代方法可以做到这一点,这样它就不会忽略命令或更好 - 一种在 Server 2008 R2
和 [=] 中都有效的方法16=]?
呃。经过多次挫折后,Set-ItemProperty
似乎是 case-sensitive,尽管 Get-ItemProperty
不是。对于所有发现此问题的人来说,解决方案非常简单:
Set-ItemProperty -Path "IIS:\AppPools\Test" -Name recycling.periodicRestart.time -Value 00:00:00
(注意 属性 名称的小写)。雪上加霜的是 Server 2012 R2
,Set-ItemProperty
在 属性 名称大小写与正确的 XML 元素名称不完全匹配的情况下静默失败(无双关语)在基础 C:\Windows\System32\inetsrv\config\applicationHost.config
文件中。