2011-06-14 35 views
4

任何人都可以請告訴我如何使用asp.net 4.0熱身機制的powershell腳本的IIS?如何使用powershell腳本進行asp.net 4.0的IIS熱身?

我創建這個PowerShell腳本,但它似乎並沒有寫什麼到applicationHost.config文件: (試圖從這裏執行第3步,但使用PowerShell:http://weblogs.asp.net/gunnarpeipman/archive/2010/01/31/asp-net-4-0-how-to-use-application-warm-up-class.aspx

Import-Module WebAdministration 

$SiteName="Default Web Site" 
$ApplicationName=「WebOne「 

Add-WebConfiguration "system.applicationHost/sites/site[@name='Default Web Site']/application[@path='WebOne']" -Value @{serviceAutoStartEnabled="true";serviceAutoStartProvider="PreWarmMyCache"} -PSPath IIS:\Sites\$SiteName\$ApplicationName -Location $SiteName/$ApplicationName 

我想添加這兩個(2)性能(serviceAutoStartEnabled="true" and serviceAutoStartProvider="PreWarmMyCache"):

如:

<application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />: 

我目前申請ication路徑:(從這裏開始第4步,但使用PowerShell:http://weblogs.asp.net/gunnarpeipman/archive/2010/01/31/asp-net-4-0-how-to-use-application-warm-up-class.aspx) :

<sites> 
    <site name="Default Web Site" id="1"> 
       <application path="/WebOne" applicationPool="ASP.NET v4.0"> 
        <virtualDirectory path="/" physicalPath="C:\NetProjects\WebOne" /> 
       </application>   
    </site> 
</sites> 

我還需要這PowerShell腳本

<serviceAutoStartProviders> 
    <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" /> 
</serviceAutoStartProviders> 

任何幫助將大大appriciated.-

我已經powershell腳本這個東西下面也是需要的,但我需要上面的東西(serviceAutoStartEnabled =「true」和serviceAutoStartProvider =「PreWarmMyCache」),我提到的.-

#Load IIS Modules 
Import-Module WebAdministration 

if (Test-Path IIS:\AppPools\SosSWarmUpWorkerProcess) 
{ 
    #Let's delete the entry if it's already there (while deploying between versions) 
    Remove-Item IIS:\AppPools\SosSWarmUpWorkerProcess -Force -Recurse 
} 

$myNewPool = New-Item IIS:\AppPools\SosSWarmUpWorkerProcess 
$myNewPool.managedRuntimeVersion = "4.0" 
$myNewPool.startMode="AlwaysRunning" 

$myNewPool | Set-Item 

回答

0

我無法找到New-Item或New-WebApplication的參數,該參數允許您爲新應用程序設置AutoStart。但是,您可以在創建應用程序後設置屬性:

$vdirPath = Join-Path "IIS:\Sites" (Join-Path $iisSite $virtualDirectoryName) 
New-Item $vdirPath -physicalPath $webSitePath -type Application 
Set-ItemProperty $vdirPath -name serviceAutoStartEnabled -value "true" 
Set-ItemProperty $vdirPath -name serviceAutoStartProvider -value "PreWarmMyCache" 
相關問題