How to set IIS ApplicationPool "Private Memory Limit" value using PowerShell
This script uses Get-Webconfiguration and Set-WebConfiguration to get the value for private memory for all app pools. You can set each individually or set the application pool defaults for them to inherit. I have commented out the line which actually does the set.
import-module webadministration$applicationPoolsPath = "/system.applicationHost/applicationPools"$applicationPools = Get-WebConfiguration $applicationPoolsPathforeach ($appPool in $applicationPools.Collection){ $appPoolPath = "$applicationPoolsPath/add[@name='$($appPool.Name)']" Get-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory" # Set-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory" -Value 1000}
I am adding an answer because I was having trouble using the existing.
import-module webadministration$applicationPools = Get-ChildItem IIS:\AppPoolsforeach ($appPool in $applicationPools){Set-ItemProperty IIS:\AppPools\$appPool.name `-Name recycling.periodicrestart.privateMemory -Value 7000000}
Your responses helped me come up with a solution to a problem that I was having with my WSUS servers. I knew that it was the application pool size for the WsusPool
that was giving me problems so I made the following PS script and applied it to the root OU
for my WSUS
servers (I have 3) I was getting a connection error and my option to Reset Server Node
didn't help. The event viewer had Event IDs 12002, 12012, 12032, 12022, 12042, 12052, and 12072.
Set-WebConfiguration "/system.applicationHost/applicationPools/add[@name='WsusPool']/recycling/periodicRestart/@privateMemory" -Value 0