Set-ItemProperty IIS:\AppPools\[App_Pool] -Name Recycling.PeriodicRestart.Time has no effect in Server 2012 R2

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:

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:

but on Server 2012 R2, I get this:

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-ItemPropertyis case-sensitive, even though Get-ItemProperty is not. To all who find this, the solution is quite simple:

(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.

Source:

Set-ItemProperty IIS:\AppPools\[App_Pool] -Name Recycling.PeriodicRestart.Time has no effect in Server 2012 R2 by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply