Warm Script that warms up across Zones and Alternate Access Mappings

All replies

  • Why not just use the AAM urls in your warmup scripts? What script are you using?
    Monday, September 30, 2013 2:47 PM
  • Hi Etala,

    I had a similar problem and found a solution on the Codeplex called SPBestWarmUp (

    It works for me but I was told these warm up scripts are not really recommended for production environments.

    What I have learned is that if your SharePoint site is busy then the wake up may not really be necessary because IIS should clear the cache if it isn't in use often. So if the site gets busy then revisit the script and you may eventually remove it. My SharePoint environment has multiple web applications so it eventually wasn't ideal for me.

    Hope this helps!


    Monday, September 30, 2013 3:13 PM
  • Hi Alex,

    All the scripts I've looked at use commands like Get-SPWebApplication or Get-SPSite to enumerate through the sites to make a list of sites to wake up. I've found though that they don't touch any other zones or AAMs

    I've haven't found a script where you give it a list of sites to wake up - if you know of one I'm more than happy to try it.

    Hi Sidney,

    I did look at SPBestWarmUp but firstly found I'd have to relax the scripting restrictions for it to run as it's not signed but when it runs it still only visits my default URLs but also threw up an error about "Cannot overwrite variable PID because it is read-only or constant" - I didn't troubleshoot it further as it wasn't touching the AAM URLs anyway.


    Monday, September 30, 2013 3:26 PM
  • Let's see if this helps...

    I had initially opened a case with Microsoft on this and they came up with the following PowerShell code. I ended up going with SPBestWarmUp but take a look at this and see if it works for you.

    This is for a specific named site.

    function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
        $error = $false
        $webRequest = [System.Net.HttpWebRequest]::Create($url)
        $webRequest.Timeout = 300000
        if($cred -eq $null)
            $webRequest.Credentials = [system.Net.CredentialCache]::DefaultCredentials
        try {
        $res = $webRequest.getresponse()
        $error = $true
    Function Load-SharePoint-Powershell
         If ((Get-PsSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null)
                  Write-Host -ForegroundColor White " - Loading SharePoint Powershell Snapin"
              Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction Stop
    $webapplications = ""
    $AllSites = Get-SPSite -limit all
    $Array = @()
    foreach ($wa in $webapplications)
        foreach ($windowsauth in $wa.AlternateUrls)
            $authenticationprovider= Get-SPAuthenticationProvider -webapplication $wa -zone $windowsauth.Zone
            If ($authenticationprovider.UseWindowsIntegratedAuthentication)
                $accessableURL = $windowsauth.IncomingUrl
        if (!$AccessableURL) {$accessableURL = $wa.url -replace ".$"}
        foreach ($site in $AllSites)
            if ($Site.Url -and $Site.Url+"/" -match $wa.url)
                $subsites = Get-SPSite $Site.Url | Get-SPWeb -Limit All
                Foreach ($subsite in $subsites)
                    Write-Progress -activity "Looking up all sites" -status "Please Wait..." -PercentComplete (($i / 500) * 100)
                    $PlainWaUrl = $wa.Url -replace ".$"
                    $WakeUpSite = $Subsite.Url.replace($PlainWaUrl, $accessableURL)
                    $Array = $Array + $WakeUpSite
                    #$html=get-webpage -url "$WakeUpSite" -cred $cred;
                    if ($i -eq 500){$i=0}
        Remove-Variable accessableURL

    Foreach ($Website in $Array)
        Write-Progress -activity "Waking up sites" -status "Waking: $Website" -PercentComplete (($i / $Array.Count) * 100)
        $html=get-webpage -url "$Website" -cred $cred;

    Monday, September 30, 2013 3:40 PM
  • I'll give that whirl Sidney - Quick question,

    Do you need to provide a list of URLs in the $webapplications = line?

    i.e. $webapplications = "","",""

    Monday, September 30, 2013 3:52 PM
  • This was a while back and I think it was for a single URL but may be run multiple times for different URLs.

    I also think it can be modified for multiple or all web applications but don't remember, sorry.

    Monday, September 30, 2013 4:47 PM
  • No joy with that scrip Sidney.

    The error I get is "Cannot bind argument to parameter "Zone" because it is null.

    I've tried to run the line

             $authenticationprovider= Get-SPAuthenticationProvider -webapplication $wa -zone $windowsauth.Zone

    as a single line, i.e. Get-SPAuthenticationProvider -webapplication <name of webapp> -zone <name of zone> but I don't get anything returned in the PowerShell window.

    Tuesday, October 01, 2013 8:53 AM