Freigeben über


MinimaList SharePoint WarmUp Script

In the spirit of Minimalism I have decided to create the simplest SharePoint warm up script that I could.  There are plenty of warm up scripts on the web.  Many of them are convoluted and difficult to manage.  This shouldn't be that difficult.  All you need to do is enumerate your web applications and site collections.  Then make a simple web call to each of them using the correct credentials.  Once you have that all you need is a scheduled task to hit them on regular intervals. 

So here it is:

$wc = New-Object net.WebClient

$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials

Get-SPSite | ForEach {$wc.DownloadString($_.url)}

 

Bing! Simple right?

This will not hit the Central Administration site.  To do this  just add the following 2 lines.

$caUrl = "*https://servername:5555"

$wc.DownloadString($caUrl)

 *Specify your specific central admin url.

______________________________________________________________________________________________________________

1. Create a PS1 file called warmup.ps1 and put these line in it:

$wc = New-Object net.WebClient

$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials

Get-SPSite | ForEach {$wc.DownloadString($_.url)}

$caUrl = "https://servername:5555"

$wc.DownloadString($caUrl)

 

2. Create a batch file with this line in it:

 powershell -command "& 'c:\warmup.ps1'"

 

3. Next you will need to setup a scheduled task.  Open Task Scheduler > Create New Task… >

 If you run this as hidden you will not see a popup.  Ensure that the task runs whether the user is logged on or not.

Set to run Daily and repeat every 10 minutes or so.  I like to ensure that the sites are fresh more often.

Select the warm up batch file that you just created.

Finally set the account that will run the scheduled task.  I would use the SharePoint System Account

______________________________________________________________________________________________________________

TESTING

On your SharePoint server temporarily change your Internet Explorer home pages to hit all of your site collections or at least web applications including Central Admin.

Test from a command line:

iisreset

powershell -command "& 'c:\warmup.ps1'"

"C:\Program Files\Internet Explorer\iexplore.exe"

 You should see your sites load very quickly.  As always please test before you try this on your production farm.

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Another point I realized later is that this will only pull up the default page of each Site Collection.  If you have custom pages that take time to load you may want to also add them to your script.  You can do this using the same method that the Central Administration site is added. $CustomPageUrl = "http://MyNameIsURL" $wc.DownloadString($CustomPageUrl) Customized or unghosted pages do not get compiled into a DLL and loaded into memory like ghosted pages.  Therefore they typically load faster than ghosted pages.  Sometimes that is not the case and adding them to the warm-up script may make the load time faster. If you haven't heard or read test everything you plan to do in Production should be TESTED on a non-Production QA environment before you do anything on your Production servers.  Your users deserve it.

  • Anonymous
    January 01, 2003
    It was brought to my attention by a colleague of mine @ blogs.msdn.com/.../sharepoint_strategery that I did not mention that the PowerShell scripts need to be run locally on each SharePoint server.  My bad.  Thanks Brian - BTW you need to actually write a blog. For clarification running the PowerShell script locally will require that you modify the local HOSTS file on each server and add each web site base URL and IP address of the local server to ensure that you are hitting the local server rather than another server in the farm. Example 127.0.0.1       localhost 47.72.23.118   SharePointStrategery.com Further reading on HOSTS files: technet.microsoft.com/.../cc751132.aspx You really need to test, test, test, before you do this in Production.  Let's not be cowboy admins out there.

  • Anonymous
    April 12, 2014
    Un “problema” conocido en las distintas versiones de SharePoint es que los Application Pools de SharePoint

  • Anonymous
    April 19, 2014
    Thanks for taking the time to post this and for your comments - very nice having those screen shots too

  • Anonymous
    May 21, 2015
    Robert, this is great, I have already seen a big improvement in my site render times. I have modified your script to add logging information as well. In my case management wanted to know how long the script ran etc. I will add my version here:

    #open logfile
    $logtime = (Get-Date -format s) -replace ":",""
    $logfile = "c:scriptsWarmupScriptLog-" + $logtime + ".txt"
    $logstring = "n&quot; &#43; &quot;PowerShell Script starting at &quot; &#43; (Get-Date)<br>Add-content $Logfile -value $logstring<br><br>$wc = New-Object net.WebClient<br><br>$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials<br><br>Get-SPSite | ForEach {<br><br>$wc.DownloadString($_.url)<br>$logstring = &quot;n" + $wc.DownloadString($
    .url)
    Add-content $Logfile -value $logstring
    }

    $caUrl = "http://yourcentraladmin"

    $wc.DownloadString($caUrl)

    #closeout log file
    $logtime = (Get-Date -format s) -replace ":","_"
    $logstring = "`n" + "Script completed at: " + $logtime
    Add-content $Logfile -value $logstring

    $wc.Dispose()