Easy SharePoint 2010 warmup Script using PowerShell

| Posted in Programming, SharePoint, 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;