Domanda

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?

È stato utile?

Soluzione

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
}

Altri suggerimenti

I am adding an answer because I was having trouble using the existing.

import-module webadministration
$applicationPools = Get-ChildItem IIS:\AppPools

foreach ($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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top