How to powershell script the IIS warm-up for 4.0 ?RSS

1 reply

Last post Dec 23, 2017 12:26 AM by AnimeNerd

  • How to powershell script the IIS warm-up for 4.0 ?

    Jun 14, 2011 07:38 AM|LordSmacker|LINK

    Hi there,

    Can anybody please tell me how to powershell script the IIS to use the 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: )

    Import-Module WebAdministration

    $SiteName="Default Web Site"

    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"):

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

    To my current Application Path:

         <site name="Default Web Site" id="1">

                    <application path="/WebOne" applicationPool="ASP.NET v4.0">
                        <virtualDirectory path="/" physicalPath="C:\NetProjects\WebOne" />

    I will also need to powershell script this:
    ( step 4 from here, but using Powershell: )

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

    Any help would be greatly appriciated.-

    I've already powershell scripted this 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 | Set-Item

  • Re: How to powershell script the IIS warm-up for 4.0 ?

    Dec 23, 2017 12:26 AM|AnimeNerd|LINK

    This worked for me:

    Set-WebConfigurationProperty -Filter "system.applicationHost/sites/site[@name='$WebSiteName']/application[@path='/']" -Name serviceAutoStartEnabled -Value True
    Set-WebConfigurationProperty -Filter "system.applicationHost/sites/site[@name='$WebSiteName']/application[@path='/']" -Name serviceAutoStartProvider -Value "YourApplicationPreload"