2012-06-25 66 views
1

我使用PowerShell中的自動部署網站設置IIS ApplicationPool「專用空間限制」值,最近發現不能用PS來設置程序池設置。或者至少我沒有設法找出如何去做。如何使用PowerShell的

$appPool = $serverManager.ApplicationPools.Add($sitename)... 

我需要「專用空間限制」設置爲某個值,但它看起來像有在ApplicationPool沒有這樣的屬性ApplicationPoolRecycling對象。

是否anybode知道這個問題的解決方法?

+0

哪個版本的IIS的? –

回答

6

此腳本使用Get-WebconfigurationSet-WebConfiguration以獲取專用內存值的所有應用程序池。您可以單獨設置每個設置或設置應用程序池的默認設置以使其繼承。我已經註明了實際上做這個集合的那一行。

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 
} 
+0

真棒,謝謝! –

1

我正在添加一個答案,因爲我在使用現有的問題時遇到了問題。

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

foreach ($appPool in $applicationPools){ 
Set-ItemProperty IIS:\AppPools\$appPool.name ` 
-Name recycling.periodicrestart.privateMemory -Value 7000000 
}