Script Download: WarmupSiteApplication.ziphttp://gallery.technet.microsoft.com/scriptcenter/PowerShell-to-Warm-Up-0988dd61
Application warm-up is requested to improve customer experience for the sites taking long time on initialization after application pool recycling.
You can find more All-In-One Script Framework script samples at http://aka.ms/onescriptingallery
Here is the script that I use. The benefit is that is uses the SharePoint snapin to determine what sites are available in the farm and hits each one to warm it up. New sites will automatically be warmed up. I schedule it on one of the web front end servers in the farm.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction:SilentlyContinue
function Get-WebPage
{
param(
[string]$url
)
Write-Host "Getting $url"
$wc = New-Object Net.Webclient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
return $wc.DownloadString($url);
}
Get-SPWebApplication -IncludeCentralAdministration | %{ Get-SPSite $_.Url } | Get-SPWeb | %{
$null = Get-WebPage -url $_.Url
$_.Lists | ?{ -not $_.Hidden } | %{
Get-WebPage "$($_.ParentWeb.Site.Url)$($_.DefaultViewUrl)" | Out-Null