Skip to content

Commit

Permalink
SharePoint WarmUp Scripts
Browse files Browse the repository at this point in the history
Added two SharePoint WarmUp Scripts to the Utils folder
  • Loading branch information
jcgonzalezmartin committed Jun 18, 2014
1 parent a713864 commit 6d34423
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
50 changes: 50 additions & 0 deletions SharePoint/Utils/PS_WarmUp_SharePoint_1.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
############################################################################################################################################
# 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
{

"Creating an Internet Explorer object for navigation."
$ie = New-Object -ComObject InternetExplorer.Application

Write-Host "Enumerate the SharePoint sites." -ForegroundColor Blue
$spWebs = Get-SPWebApplication -IncludeCentralAdministration | Get-SPSite | Get-SPWeb -Limit All

"Navigating to all $($spWebs.Count) sites."
foreach ($spWeb in $spWebs)
{
"Initializing $($spWeb.URL)"
$ie.Navigate($spWeb.URL)
while ($ie.Busy)
{
Start-Sleep -Seconds 1
}
Write-Host "SharePoint Site $($ie.Document.title) has been initialized" -ForegroundColor Blue
}
$ie.Quit()
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
37 changes: 37 additions & 0 deletions SharePoint/Utils/PS_WarmUp_SharePoint_2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
############################################################################################################################################
# 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

0 comments on commit 6d34423

Please sign in to comment.