Who's Online
12 visitors online now
2 guests, 10 bots, 0 members
Support my Sponsor

SharePoint 2010 \ 2013 warm up scripts using Powershell

SharePoint app pools recycle every night so that old data is flushed and cache is cleared. It is also important from secruity aspects. But because they recycle every night the first person to hit SharePoint each morning has to wait for the app pools to warm back up, which makes them cranky. Over the years a variety of startup scripts have been written to address this, and they all work to varying degrees.

Server Side Warm script

THis script will request the default page of the root site collection of each web application in your farm:
############## Script 1 #################
Get-SPWebApplication | ForEach-Object { Invoke-WebRequest $_.url -UseDefaultCredentials -UseBasicParsing }
############## Script 1 #################

The –UseDefaultCredentials parameter tells Invoke-WebRequest to log in to the web site as the person that PowerShell is running as. –UseBasicParsing tells Invoke-WebRequest to use basic parsing of the web page. We really don’t care about the web page, we just want to wake SharePoint up to send it to us.
You can also try below Warm up script and check if can be of any help.
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
############## Script 2 #################
$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;
}
}
############## Script 2 #################
The next script is completely Powershell from http://www.jonthenerd.com/2011/04/19/easy-sharepoint-2010-warmup-script-using-powershell/

############## Script 3 #################
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;
}

############## Script 3 #################

Leave a Reply