How to set IIS ApplicationPool "Private Memory Limit" value using PowerShell
iis, powershell, web-administration
Solution
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 $applicationPoolsPath
foreach ($appPool in $applicationPools.Collection)
{
$appPoolPath = "$applicationPoolsPath/add[@name='$($appPool.Name)']"
Get-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory"
# Set-WebConfiguration "$appPoolPath/recycling/periodicRestart/@privateMemory" -Value 1000
}
Problem
I'm using PowerShell for auto-deploying website, and recently found AppPool setting which cannot be set with PS. or at least I did not manage to find out how to do it. ``` $appPool = $serverManager.ApplicationPools.Add($sitename)... ``` I need to set "Private Memory Limit" to some value, but it looks like there is no such property at ApplicationPool or ApplicationPoolRecycling object. Does anybode know workaround for this issue?