Can anybody please tell me how to powershell script the IIS to use the asp.net 4.0 warm-up mechanism?
I've created this powershell script, but it doesn't seem to write anything into the applicationHost.config file: ( trying to implement step 3 from here, but using 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
I'm trying to add these two(2) properties ( serviceAutoStartEnabled="true" and serviceAutoStartProvider="PreWarmMyCache"):
e.g.:
<application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />:
To my current Application Path:
<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>
I will also need to powershell script this: ( step 4 from here, but using Powershell: http://weblogs.asp.net/gunnarpeipman/archive/2010/01/31/asp-net-4-0-how-to-use-application-warm-up-class.aspx )
<serviceAutoStartProviders>
<add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" />
</serviceAutoStartProviders>
Any help would be greatly appriciated.-
I've already powershell scripted this 开发者_JS百科stuff below which is also needed, but I need the stuff above ( serviceAutoStartEnabled="true" and serviceAutoStartProvider="PreWarmMyCache" ), which I mentioned.-
#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
I wasn't able to find a parameter to New-Item or New-WebApplication that allows you to set the AutoStart for the new application. But, you can set the property after creating the app:
$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"
精彩评论