Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

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:

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:

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?

like image 229
James Avatar asked Nov 06 '15 21:11

James


1 Answers

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:

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.

like image 187
James Avatar answered Nov 15 '22 05:11

James