Blog
May 30
Warm it Up and Not?

So why is it important to warm up all web applications and site collections in SharePoint OnPrem?   Its pretty cut and dry here.   It makes the site faster and helps users do the actions that SharePoint has been built on.   The reason is that this needs to be done is because IIS recycles Application Pools on a nightly basis.    This is a default within the Application Pool itself.    So hear is a simple script to do so that can easily be modified with your Web Application URL and site collection URL

Here is an example of the Powershell script.   All you have to do is tweak it for your environment and set it as a Windows Taks and you just let it work.

#------------------

# Adds in the Powershell Snapin for SharePoint

#------------------

if ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {

    Add-PSSnapin "Microsoft.SharePoint.PowerShell"

}

 

 #------------------

# Changes the color to highlight information to tell you its working

#------------------

function Write-Status([Microsoft.PowerShell.Commands.WebResponseObject] $response) {

    $foregroundColor = "Red"

    if($response.StatusCode -eq 200) {

        $foregroundColor = "Orange"

    }

    write-host ([string]::Format("{0} (Status code: {1})", $response.StatusDescription, $response.StatusCode)) -ForegroundColor $foregroundColor }

 

 

#------------------

# Warm-up all web applications and pulls all the web applications that are in the farm

#------------------

Get-SPWebApplication | ForEach-Object {

    write-host ([string]::Format("WebApplication request fired for {0} [{1}]. ", $_.DisplayName, $_.Url)) -NoNewline

    Write-Status -response (Invoke-WebRequest $_.url -UseDefaultCredentials -UseBasicParsing) }

 

 

#------------------

# Since the root of web applications use templates that are custom to the specific site collection it will also load other sites of different # types. This makes sure their assemblies also get loaded in memory

#------------------

$additionalUrls = @("https://sharepoint.jmlfdc.mil/sites/search" ;, "https://sharepoint.jmlfdc.mil" ;, 

"https://sptoby.com/sites/ContentHub" ;,                          

"https://sptoby.com/sites/CSI"  ;,                                

"https://sptoby.com/sites/csi1" ;,                                

" ;) $additionalUrls | ForEach-Object {

    write-host ([string]::Format("Additional web request fired for Url: {0}. ", $_)) -NoNewline

    Write-Status -response (Invoke-WebRequest $_ -UseDefaultCredentials -UseBasicParsing) }

Comments

There are no comments for this post.

Comments

There are no comments for this post.

 ‭(Hidden)‬ Blog Tools ‭[2]‬

 ‭(Hidden)‬ Blog Tools ‭[3]‬