Buenas,
En este post queríamos hablar sobre una manera de reducir el tiempo empleado en instalar determinadas actualizaciones acumulativas, los cuales pueden llegar a tardar un tiempo considerable (cuestión de horas.)
Para ello hemos seguido este post de Russ Maxwell:
En él, se nos indican los pasos que ejecuta el script de Powershell que ha escrito, el cual automatiza y mejora el tiempo empleado en instalar cada actualización acumulativa. Los pasos que se realizan son:
01.- Deshabilitar el servicio de IISAdmin y SPTimerV4.
02.- Parar los servicios mencionados en el punto 01.
03.- Ofrece la opción de pausar el servicio de la aplicación de búsqueda.
04.- Parar los servicios de búsqueda.
05.- Instalar la actualización en modo pasivo (no requiere interacción del usuario pero monitoriza el progreso de instalación desde la interfaz gráfica.)
Nota: PowerShell debe permanecer abierto mientras se ejecuta la instalación.
06.- Después de que se complete la instalación, los servicios del paso 01 se ponen de vuelta en modo Automático
07.- Arranca los servicio IIS Admin y Timer (SharePoint)
08.- Arranca los servicios de Búsqueda
09.- Resume el servicio de aplicación de Búsqueda si estuviera pausado
10.- Por último muestra el tiempo de comienzo y finalización de la instalación.
Notas respecto a la Búsqueda:
01.- El script sólo parará los servicios de Búsqueda de SharePoint si están ejecutándose
02.- El script sólo pausará la aplicación de los servicios de Búsqueda de SharePoint bajo indicación del usuario
03.- El script sólo arrancará los servicios de Búsqueda de SharePoint si están parados
04.- El script sólo resumirá los servicios de Búsqueda de SharePoint si estaban pausados
Instrucciones para ejecutar el script de PowerShell
Para ejecutar el script, debemos copiarlo en un fichero de texto, y guardarlo con una extensión .ps1 en una carpeta del servidor que vayamos a “parchear”, donde tengamos la actualización acumulativa. Es importante que tengamos en cuenta que sólo debemos instalar una actualización cada vez que ejecutemos el script, y que la extensión del fichero debiera ser .exe.
Finalmente, tenemos que ejecutar el script desde SharePoint Management Shell.
Copiamos a continuación el script ofrecido por Russ:
<<<<<<<<<<<<<<<<<<<<<<
<# ==============================================================
//
// Microsoft provides programming examples for illustration only,
// without warranty either expressed or implied, including, but not
// limited to, the implied warranties of merchantability and/or
// fitness for a particular purpose.
//
// This sample assumes that you are familiar with the programming
// language being demonstrated and the tools used to create and debug
// procedures. Microsoft support professionals can help explain the
// functionality of a particular procedure, but they will not modify
// these examples to provide added functionality or construct
// procedures to meet your specific needs. If you have limited
// programming experience, you may want to contact a Microsoft
// Certified Partner or the Microsoft fee-based consulting line at
// (800) 936-5200 .
//
// For more information about Microsoft Certified Partners, please
// visit the following Microsoft Web site:
// https://partner.microsoft.com/global/30000104
//
// Author: Russ Maxwell (russmax@microsoft.com)
//
// ---------------------------------------------------------- #>
###########################
##Ensure Patch is Present##
###########################
$patchfile = Get-ChildItem | where{$_.Extension -eq ".exe"}
if($patchfile -eq $null)
{
Write-Host "Unable to retrieve the file. Exiting Script" -ForegroundColor Red
Return
}
########################
##Stop Search Services##
########################
##Checking Search services##
$srchctr = 1
$srch4srvctr = 1
$srch5srvctr = 1
$srv4 = get-service "OSearch15"
$srv5 = get-service "SPSearchHostController"
If(($srv4.status -eq "Running") -or ($srv5.status-eq "Running"))
{
Write-Host "Choose 1 to Pause Search Service Application" -ForegroundColor Cyan
Write-Host "Choose 2 to leave Search Service Application running" -ForegroundColor Cyan
$searchappresult = Read-Host "Press 1 or 2 and hit enter"
Write-Host
if($searchappresult -eq 1)
{
$srchctr = 2
Write-Host "Pausing the Search Service Application" -foregroundcolor yellow
Write-Host "This could take a few minutes" -ForegroundColor Yellow
$ssa = get-spenterprisesearchserviceapplication
$ssa.pause()
}
elseif($searchappresult -eq 2)
{
Write-Host "Continuing without pausing the Search Service Application"
}
else
{
Write-Host "Run the script again and choose option 1 or 2" -ForegroundColor Red
Write-Host "Exiting Script" -ForegroundColor Red
Return
}
}
Write-Host "Stopping Search Services if they are running" -foregroundcolor yellow
if($srv4.status -eq "Running")
{
$srch4srvctr = 2
set-service -Name "OSearch15" -startuptype Disabled
$srv4.stop()
}
if($srv5.status -eq "Running")
{
$srch5srvctr = 2
Set-service "SPSearchHostController" -startuptype Disabled
$srv5.stop()
}
do
{
$srv6 = get-service "SPSearchHostController"
if($srv6.status -eq "Stopped")
{
$yes = 1
}
Start-Sleep -seconds 10
}
until ($yes -eq 1)
Write-Host "Search Services are stopped" -foregroundcolor Green
Write-Host
#######################
##Stop Other Services##
#######################
Set-Service -Name "IISADMIN" -startuptype Disabled
Set-Service -Name "SPTimerV4" -startuptype Disabled
Write-Host "Gracefully stopping IIS W3WP Processes" -foregroundcolor yellow
Write-Host
iisreset -stop -noforce
Write-Host "Stopping Services" -foregroundcolor yellow
Write-Host
$srv2 = get-service "SPTimerV4"
if($srv2.status -eq "Running")
{$srv2.stop()}
Write-Host "Services are Stopped" -ForegroundColor Green
Write-Host
Write-Host
##################
##Start patching##
##################
Write-Host "Patching now keep this PowerShell window open" -ForegroundColor Magenta
Write-Host
$starttime = Get-Date
$filename = $patchfile.basename
$arg = "/passive"
Start-Process $filename $arg
Start-Sleep -seconds 20
$proc = get-process $filename
$proc.WaitForExit()
$finishtime = get-date
Write-Host
Write-Host "Patch installation complete" -foregroundcolor green
Write-Host
##################
##Start Services##
##################
Write-Host "Starting Services Backup" -foregroundcolor yellow
Set-Service -Name "SPTimerV4" -startuptype Automatic
Set-Service -Name "IISADMIN" -startuptype Automatic
##Grabbing local server and starting services##
$servername = hostname
$server = get-spserver $servername
$srv2 = get-service "SPTimerV4"
$srv2.start()
$srv3 = get-service "IISADMIN"
$srv3.start()
$srv4 = get-service "OSearch15"
$srv5 = get-service "SPSearchHostController"
###Ensuring Search Services were stopped by script before Starting"
if($srch4srvctr -eq 2)
{
set-service -Name "OSearch15" -startuptype Automatic
$srv4.start()
}
if($srch5srvctr -eq 2)
{
Set-service "SPSearchHostController" -startuptype Automatic
$srv5.start()
}
###Resuming Search Service Application if paused###
if($srchctr -eq 2)
{
Write-Host "Resuming the Search Service Application" -foregroundcolor yellow
$ssa = get-spenterprisesearchserviceapplication
$ssa.resume()
}
Write-Host "Services are Started" -foregroundcolor green
Write-Host
Write-Host
Write-Host "Script Duration" -foregroundcolor yellow
Write-Host "Started: " $starttime -foregroundcolor yellow
Write-Host "Finished: " $finishtime -foregroundcolor yellow
Write-Host "Script Complete"
>>>>>>>>>>>>>>>>>>>>