Easy SharePoint 2010 warmup Script using PowerShell

This idea comes from Kirk Hofer’s blog, but modfied to use the SharePoint 2010 powershell commandlets and not care about specifying credentials in the script. I figured most people would just keep using the credentials specified in their scheduled task.

The script loads the SharePoint plugin, enumerates the zones, and sends a request to each one.

Add-PSSnapin Microsoft.SharePoint.PowerShell;

function Get-WebPage([string]$url)
{
    $wc = new-object net.webclient;
    $wc.credentials = [System.Net.CredentialCache]::DefaultCredentials;
    $pageContents = $wc.DownloadString($url);
    $wc.Dispose();
    return $pageContents;
}

Get-SPAlternateUrl -Zone Default | foreach-object {
    write-host $_.IncomingUrl;
    $html = Get-WebPage -url $_.IncomingUrl;
}

11 thoughts on “Easy SharePoint 2010 warmup Script using PowerShell

  1. Pingback: SharePoint warmup script for loadblanced WFE’s | Bram's SharePoint Adventure

  2. Pingback: Roundup: SharePoint Warm-Up Scripts

  3. Pingback: SharePoint 2010 WarmUp « There's always a solution in the wood of features

  4. Pingback: Run Warmup Script on Startup | SharePointed

  5. Pingback: Sharepoint Warmup Script « Sharepoint…

  6. Pingback: SP Warm-up « RaSor's Blog

  7. amac44

    Commenting on an older post … but thanks for this, much simpler than other stuff out there. Note you’re assuming there’s a site collection at the root of the web app. This might not always be the case. Could do something like,

    $wa = Get-SPWebApplication $url
    $siteurl = $wa.Sites[0].Url
    $pageContents = $wc.DownloadString($siteurl)

    Reply
    1. Jon Badgett Post author

      You’re right on the assumption. I don’t know that I’ve ever seen an app configured without a root site collection, but it’s probably doable. Glad you enjoyed the script!

      Reply
  8. Pingback: Setting up an IIS Warm-up Script in an automated fashion ← Henrik Palm

  9. Pingback: SharePoint WarmUp | Sladescross's Blog

  10. Pingback: Good morning, SharePoint, your wakeup call | SharePoint Tricks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>