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 $_
}```
#Trying to set App Pool Recycle Time for IIS via PowerShell but trouble having am I.
1 messages · Page 1 of 1 (latest)
You could try this I dont know much about IIS but I found this example and modified it slightly
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.
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
Nifty
Always more to learn… 10 years I’ve been spending most of my days working with PowerShell and I’m always learning more. 😁
10 years wow, I only started learning powershell like 6 months ago. Its been a cool icebreaker for C#
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…