Warming up a SharePoint 2010 Server with PowerShell

February 17, 2011 at 12:34 pm Leave a comment

In looking for an updated way to warm up SharePoint 2010 sites to improve the user experience I cam across a PowerShell script at the following site:

http://nearbaseline.com.au/blog/2010/02/powershell-warmup-script-2/

############################################################################
#WarmUp2.ps1 – Enumerates all web sites in web applications in a 2010
# SharePoint farm and opens each in a browser.
#Notes:
#-“get-webpage” function borrowed from:
# http://kirkhofer.wordpress.com/2008/10/18/sharepoint-warm-up-script/
#
#Assumptions:
#-Running on machine with WSS/MOSS 2010 installed
############################################################################

Add-PsSnapin Microsoft.SharePoint.PowerShell
$extrasitelistfile = ‘c:\Tools\Warmup\warmup-extrasites.txt’

function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
{
$wc = new-object net.webclient
if($cred -eq $null)
{
$cred = [System.Net.CredentialCache]::DefaultCredentials;
}
$wc.credentials = $cred;
return $wc.DownloadString($url);
}

#This passes in the default credentials needed. If you need specific
#stuff you can use something else to elevate basically the permissions.
#Or run this task as a user that has a Policy above all the Web
#Applications with the correct permissions

$cred = [System.Net.CredentialCache]::DefaultCredentials;
#$cred = new-object System.Net.NetworkCredential(“username”,”password”,”machinename”)

$apps = get-spwebapplication -includecentraladministration
foreach ($app in $apps) {
$sites = get-spsite -webapplication $app.url
foreach ($site in $sites) {
write-host $site.Url;
$html=get-webpage -url $site.Url -cred $cred;
}
}
# Warm up other sites specified in warmup-extrasites.txt file (such as SSRS)

if (test-path $extrasitelistfile) {
$extrasites = get-content $extrasitelistfile
foreach ($site in $extrasites) {
write-host $site;
$html=get-webpage -url $site -cred $cred;
}
}

Advertisements

Entry filed under: SharePoint 2010.

C# MessageBox with Time Out Using Common Parameters in PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

February 2011
M T W T F S S
« Dec   Mar »
 123456
78910111213
14151617181920
21222324252627
28  

Most Recent Posts


%d bloggers like this: