“Warm up” SharePoint On-Prem

After SharePoint On-Prem has not been used for a while (an hour or so), it can take a while to “warm” up and get back to normal responsiveness. To prevent this from happening you can use PowerShell scripts and batch files to keep the sites “warm” by hitting the home page periodically. You can do this by following these steps.

  1. Make sure each web front end can run scripted PowerShell commands by running this PowerShell command on each of the servers.

    set-executionpolicy RemoteSigned
  2. Create a PowerShell script on each front end server in notepad and save it as something appropriate (i.e. warmup.ps1 making sure it doesn’t have the txt extension) and put it somewhere accessible on the server (i.e. c:\scripts). The contents of the script should be as follows.

    Get-SPWebApplication | ForEach-Object {
    Invoke-WebRequest $_.url -UseDefaultCredentials -UseBasicParsing }
  3. Create a batch file on each server (i.e. warmup.bat) using notepad and also put it some place accessible (i.e. c:\scripts). The batch file should contain the following line of code pointing to the PowerShell script created in step 2 as shown below.

    powershell -command Add-PSSnapin “Microsoft.SharePoint.PowerShell”
    powershell -command “& ‘c:\scripts\warmup.ps1’
  4. Open up the “Task Scheduler” and create a scheduled task on each web front end that runs the batch file (i.e. c:\scripts\warmup.bat) with an account that has enough rights to execute the file. Running it every thirty minutes should keep it refreshed enough that users won’t get a long delay when they go to the site.

    Important: Make sure the task runs whether the account is logged on or not (under properties as shown below).