I just did this and was frankly awash in a sea of misinformation, so here’s how it’s done.
$ValueToSet = 40 $AppPoolPrefix = "*" $appPools = gci IIS:\AppPools | ? {$_.Name -like $AppPoolPrefix} $appPools | % { $currentTimeout = $_.processModel.IdleTimeOut if($ValueToSet -ne $CurrentTimeout.Minutes) { $_.processModel.IdleTimeout = [TimeSpan]::FromMinutes($ValueToSet) $_ | Set-Item Write-Host "Set" $_.Name "to" $_.processModel.IdleTimeout } }
What are the gotchas here?
Well one, just calling Set-ItemProperty does nothing but apply your change to an in-memory copy of the object. Not the object itself. Forget that solution
Second, you need to pass in a timespan object, not merely a straight number, or you’ll get unexpected results when it tries to set the timeout in ticks
Third: Do not forget the Set-Item call, or you’re utterly lost.
And that’s about it.
[update: I forgot to say, include:
Import-Module WebAdministration
At the start. I don’t have to, because my servers ipmo that module in their PowerShell profiles. But you’ll need to.]
thank you- you’re right about there being a ton of misinformation online about this…. 🙂