如何为asp.net 4.0编写IIS预热脚本?

如何为asp.net 4.0编写IIS预热脚本?,iis,powershell,Iis,Powershell,有谁能告诉我如何为IIS编写powershell脚本以使用asp.net 4.0预热机制吗 我创建了此powershell脚本,但它似乎没有将任何内容写入applicationHost.config文件: (尝试从此处实施步骤3,但使用Powershell:) 我正在尝试添加这两(2)个属性(serviceAutoStartEnabled=“true”和serviceAutoStartProvider=“PreWarmMyCache”): e、 g: 我无法找到允许您为新应用程序设置自动启动的N

有谁能告诉我如何为IIS编写powershell脚本以使用asp.net 4.0预热机制吗

我创建了此powershell脚本,但它似乎没有将任何内容写入applicationHost.config文件: (尝试从此处实施步骤3,但使用Powershell:)

我正在尝试添加这两(2)个属性
(serviceAutoStartEnabled=“true”和serviceAutoStartProvider=“PreWarmMyCache”):

e、 g:


我无法找到允许您为新应用程序设置自动启动的New Item或New WebApplication的参数。但是,您可以在创建应用程序后设置属性:

$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"
<application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />:
<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>
<serviceAutoStartProviders>
     <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" />
</serviceAutoStartProviders>
#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
$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"