This script is intended to do a warm up for all the SharePoint sites in a SharePoint farm. The scripts allows to do a first navigation to each site in the farm improving user experience in that way so every user accessing for the first time to a site is not penalized by the SharePoint Application Pools recycle process performed by SharePoint every night. This Script is only valid for SharePoint 2013.

 

PowerShell
Editar script|Remove
############################################################################################################################################ 
# Script that allows to Warm Up all the sites in a SharePoint Farm. 
# Required Parameters: None 
############################################################################################################################################ 
 
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )  
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell } 
 
$host.Runspace.ThreadOptions = "ReuseThread" 
 
Start-SPAssignment –Global 
 
#Definición de la función que obtiene el tamaño de las BD's de contenidos 
function Do-WarmUp 
{   
    try 
    { 
        Write-Host "SharePoint Initialization Processs Completed succesfully!" -ForegroundColor Blue         
        $spWebApps = Get-SPWebApplication -IncludeCentralAdministration         
        foreach ($spWebApp in $spWebApps) 
        {            
            Write-Host "Initializing $($spWebApp.URL)" 
            Invoke-WebRequest $spWebApp.URL -UseDefaultCredentials -UseBasicParsing                                
        }          
        Write-Host "SharePoint Initialization Processs Completed succesfully!" -ForegroundColor Blue 
    } 
    catch 
    { 
        Write-Host -Object ("Status: " + $Error[0].Exception.Message) -ForegroundColor Red 
    } 
} 
 
Start-SPAssignment –Global 
Do-WarmUp 
Stop-SPAssignment –Global 
 
Remove-PsSnapin Microsoft.SharePoint.PowerShell