3

Can anybody provide a copy of, or a link to, a reliable powershell warm-up Script for SharePoint 2010.

Ideally I want this to run shortly after the app pool has recycled overnight.

Our configuration is two front end Web servers in a load balancer.

Thanks

1

This script from MSFT employee which will handle the load balanced environment. Warm-up Script for Web Front End Servers (WFE) in Load Balanced SharePoint Farms

These are the steps:

  1. OPEN POWERSHELL ISE OR POWERSHELL AS A FARM ADMIN
  2. COPY AND PASTE THE POWERSHELL BELOW (Between the "#--------------------------")
  3. TEST THE SCRIPT TO ENSURE NO ERRORS OCCUR SAVE THE FILE AS A .PS1 TYPE IN A DESIGNATED LOCATION e.g. c:\powershell\warmupscript.ps1
  4. SCHEDULE A WINDOWS TASK TO RUN AFTER THE LAST APPLICATION POOL IS RECYCLED (4am should be safe)

    PowerShell Starts here

    --------------------------------------------------

    Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue

    function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
     {
    
       $bypassonlocal = $false
       $proxyuri = "http://" + $env:COMPUTERNAME
       $proxy = New-Object system.Net.WebProxy($proxyuri, $bypassonlocal)
       $wc = new-object net.webclient
       $wc.Proxy = $proxy
       if($cred -eq $null)
       {
    
         $cred = [System.Net.CredentialCache]::DefaultCredentials;
    
       }
    
       $wc.credentials = $cred;
       return $wc.DownloadString($url);
     }
    
     $cred = [System.Net.CredentialCache]::DefaultCredentials;
    

    This can be used if required to force using certain credentials

     #$cred = new-object    System.Net.NetworkCredential("username","password","machinename")
    

    Get the Web Apps

    $apps = get-spwebapplication # -includecentraladministration (Central admin is not included as it is not running on my WFE Server)

    foreach ($app in $apps) { #Get the Site Collections $sites = get-spsite -webapplication $app.url -Limit All

    ### UNCOMMENT THE 2 LINES BELOW IF YOU ONLY WANT TO USE THIS AT SITE COLLECTION LEVEL - Not required if Sites are warmed up.

    #write-host $app.Url; #$html=get-webpage -url $app.Url -cred $cred;

    ###COMMENT OUT BETWEEN THE "=======" IF THERE ARE TOO MANY WEBs i.e. Sites and you don't want to warm them up.

    #==================

    foreach ($site in $sites) {
      foreach ($web in $site.AllWebs) {
      #get the webs i.e. Sites
          write-host $web.Url;
          $html=get-webpage -url $web.Url -cred $cred;
     }
    }
    #=================
    

    }

    --------------------------

  • Thanks - this looks good. Does this have to be run on each server with IIS, or just one of the Web Front End Servers? – Molenpad Dec 2 '17 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.