SharePoint Powershell Warm Up Script

I take no credit for this, I found it at Kirk Hofer’s blog, and thought I would share it as well.

######################################################################
#Assumptions:
#-Running on machine with WSS/MOSS
#-C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN in path
######################################################################

function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
{
$wc = new-object net.webclient
if($cred -eq $null)
{
$cred = [System.Net.CredentialCache]::DefaultCredentials;
}
$wc.credentials = $cred;
return $wc.DownloadString($url);
}

#This passes in the default credentials needed.  If you need specific stuff you can use something else to
#elevate basically the permissions.  Or run this task as a user that has a Policy above all the Web Applications
#with the correct permissions
$cred = [System.Net.CredentialCache]::DefaultCredentials;
#$cred = new-object System.Net.NetworkCredential(“username”,”password”,”machinename”)

[xml]$x=stsadm -o enumzoneurls
foreach ($zone in $x.ZoneUrls.Collection) {
[xml]$sites=stsadm -o enumsites -url $zone.Default;
foreach ($site in $sites.Sites.Site) {
write-host $site.Url;
$html=get-webpage -url $site.Url -cred $cred;
}
}

2 Responses to “SharePoint Powershell Warm Up Script”

  1. kirkhofer Says:

    Check our my newly updated script. It is much better and actually works :( http://kirkhofer.wordpress.com/2008/10/18/sharepoint-warm-up-script/

  2. [...] also had trouble getting a warm up script that worked, and we’ve tried several.  We had it working at one time, prior to going to [...]

Leave a Reply