Answered by:
Setting Recycling->Specific Times for application pools

Question
-
User-1124987475 posted
Hi
I am trying to set up a series of application pool properties using a PS script. However, one of the properties, Recycling -> Specific Times causes some problems. I have tried several approaches, but I can’t seem to get it set.
The following snippet is accepted with no errors, but the change is not registered:
Set-ItemProperty IIS:\AppPools\[poolName] -Name Recycling.PeriodicRestart.Schedule -Value (New-TimeSpan -h 22 -m 00)
The same applies if I replace the specified TimeSpan value with “22:00:00” or [TimeSpan] “22:00:00”.
I have also tried the below snippet which has no effect either:
[TimeSpan[]] $x = ((New-TimeSpan -h 22 -m 00))<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>Set-ItemProperty IIS:\AppPools\CrmDashboards -Name Recycling.PeriodicRestart.Schedule -Value $x<o:p></o:p>
Does anyone have a hint to what I am doing wrong? Thanks!Tuesday, November 23, 2010 7:11 AM
Answers
-
User1207794388 posted
Keev,
I was doing this today, but to the "applicationPoolDefaults" and it works fine for me.
Maybe it will help you.
# clean all scheduled recycles
Clear-WebConfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule
# add periodic recycle (1h30)
add-webconfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule -value (New-TimeSpan -h 1 -m 30)
# check if the recycle was added
get-webconfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule/add | select value
Hope that I'm helping.
Regards
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Sunday, November 28, 2010 5:02 PM
All replies
-
User1207794388 posted
Keev,
I was doing this today, but to the "applicationPoolDefaults" and it works fine for me.
Maybe it will help you.
# clean all scheduled recycles
Clear-WebConfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule
# add periodic recycle (1h30)
add-webconfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule -value (New-TimeSpan -h 1 -m 30)
# check if the recycle was added
get-webconfiguration /system.applicationHost/applicationPools/applicationPoolDefaults/recycling/periodicRestart/schedule/add | select value
Hope that I'm helping.
Regards
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Sunday, November 28, 2010 5:02 PM -
User1222388420 posted
Did you figure out how to do this? I am struggling with the same issues.Wednesday, March 30, 2011 3:53 PM -
User-1672167363 posted
Hello @ Craig,
As you may have noticed this is an old thread and the user has answer for the specific Issue.
It is very likey the User will not be following this Thread to provide an answer.
I might be best to open a new Post in the Trouble Shooting or Administration Forum
with the details for Your System and the Issues your having.
You could also look at the current suggested settings in the IIS Net library here http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add/recycling .
The best way to get answers for problems is with creating a post & question.
Thank you for understanding,
Martin
Wednesday, March 30, 2011 4:19 PM -
User-1124987475 posted
Hi,
Sorry for the very late answer and thank you for the suggestion. Unfortunately, I tried the suggested approach on "applicationPoolDefault" where it works, but for other app pools there is no luck. It seems it only works when changing defaults. I ended up using appcmd instead, it does the trick with no problems.
Sunday, April 3, 2011 1:25 PM -
User-1858245506 posted
On a similar note,
Howdo set up an Application Pool to recycle at a specific time of the day using PowerShell?
Friday, June 10, 2011 8:26 AM -
User-1381735367 posted
"applicationPoolDefault" will set the default values for the new app pools to be created afterwords. To create a value for a specific AppPool you can the following:
clear-ItemProperty IIS:\AppPools\MyPoolName -Name Recycling.periodicRestart.schedule #clear the existing values
set-ItemProperty IIS:\AppPools\MyAppPoolName -Name Recycling.periodicRestart.schedule -Value @{value="03:00:00"} #to set it to 3 AMWednesday, February 29, 2012 10:31 AM