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);
    return $pageContents;

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

8 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)

    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!


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=""> <s> <strike> <strong>