#Trying to set App Pool Recycle Time for IIS via PowerShell but trouble having am I.

1 messages · Page 1 of 1 (latest)

unkempt hollow
#
Import-Module WebAdministration
try {
    $PrivateMemory = 1468006
    $PoolPath = Resolve-Path "IIS:/AppPools/"
    (Get-WebConfiguration $PoolPath).Collection | ForEach-Object -Process {
        $AppPath = "$PoolPath/add[@name='$($_.Name)']"
        Get-WebConfiguration "$AppPath/recycling/periodicRestart/@privateMemory"
        Set-WebConfiguration "$PoolPath/recycling/periodicRestart/@privateMemory" -Value $PrivateMemory
    } 
}
catch {
    Write-Host $_
}```
#

You could try this I dont know much about IIS but I found this example and modified it slightly

#
unkempt hollow
#

try using a try catch? also the list of times you have are in a string format. Maybe use (Get-Date -Hour 0 -Minute 15 -Format hh:mm)

#

Its hard to tell what the issue is without an error message.

#

if you want the script to run at a certain time. Maybe use task scheduler? I don't know much about IIS I was just trying to be helpful since no one else responded. I figured I might learn something in the process.

modern yacht
#

If you’re running in Pwsh do (Get-Error -Newest 1).Exception.Message after you get an error and post the output so we can better assist. Or in PowerShell.exe $Error[0].Exception.Message

modern yacht
#

Always more to learn… 10 years I’ve been spending most of my days working with PowerShell and I’m always learning more. 😁

unkempt hollow
modern yacht
#

Yep! I totally agree. PowerShell was the catalyst for my renewed interest in programming. After a very poor decision in my teens to teach myself some C++ and hating it…

pliant shard
#

"I have the following code. I am trying to set to specific time(s) to recycle."

#

LOL You BIG DUMB