I'm trying to set the periodicRestart
property using a powershell script, but I'm trying to use a slightly different syntax than what I've seen in code samples.
Here's one way to do according to Set the specific times to recycle an application pool with PowerShell:
Clear-ItemProperty $iisAppPoolName -Name Recycling.periodicRestart.schedule
Set-ItemProperty $iisAppPoolName -Name Recycling.periodicRestart.schedule `
-Value @{value="01:00:00"}
However, I already have a block of code where I'm setting properties on the $appPool
itself like this:
$appPool = New-WebAppPool $iisAppPoolName
$appPool.managedPipelineMode = "Classic"
$appPool.managedRuntimeVersion = "c4.0"
$appPool.recycling.periodicRestart.time = [TimeSpan]"00:00:00"
$appPool | Set-Item
Which works fine, so I'd like to add the following line:
$appPool.recycling.periodicRestart.schedule = @{value="01:00:00"}
But I can't get the syntax for @{value="01:00:00"}
to take. The schedule
property is expecting a hashtable which is what I'm passing it.
Any ideas?