Question:
I’ve got a couple of farms of servers, one with Server 2008 R2
and one with Server 2012 R2
. After a bunch of searching, I found the following powershell to disable default IIS application pool recycling, which I run at an administrative powershell prompt:
1 2 |
Set-ItemProperty IIS:\AppPools\Test -Name Recycling.PeriodicRestart.Time -Value 0 |
This seems to work fine (it runs without any output on either platform), but when I subsequently attempt to query the value, on Server 2008 R2
, I get this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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 |
but on Server 2012 R2
, I get this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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 |
Notice that the Value
in the first example is 00:00:00
, but in the second example is 1.05:00:00
. This is the default value inherited from the DefaultAppPool
.
I’ve attempted to change the value for DefaultAppPool
as well, but I get the same results–it works on 2008 R2
but not on 2012 R2
, so I’m fairly certain that inheritance isn’t the issue.
Is there some alternate way to do this in Server 2012 R2
so that it doesn’t ignore the command or better yet–a way to do it that works in both Server 2008 R2
and Server 2012 R2
?
Answer:
Ugh. After much frustration, it appears that Set-ItemProperty
is case-sensitive, even though Get-ItemProperty
is not. To all who find this, the solution is quite simple:
1 2 |
Set-ItemProperty -Path "IIS:\AppPools\Test" -Name recycling.periodicRestart.time -Value 00:00:00 |
(notice the lower-casing on the property name). To add insult to injury in Server 2012 R2
, Set-ItemProperty
fails silently in the case (no pun intended) where the property name casing doesn’t exactly match the proper XML element names in the underlying C:\Windows\System32\inetsrv\config\applicationHost.config
file.