SharePoint 2013 Cumulative Update takes long time to install

Sometimes, if you have tried to install SharePoint 2013 /2016 Cumulative Update takes long time about 4 hours or more to be installed!

In this article, we will explain how to avoid the long time to install a new cumulative update in SharePoint farm by following the below instructions.

SharePoint Cumulative Update takes long time to install

  • Copy the below script (at the end of article) to a notepad file and change its extension to ps1.
###########################
##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

Start-Process $filename

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"
  • Create a new folder in C:\\ Drive.
  • Copy the CU file with “exe” extension in the newly created folder.

Note: if you have multiple update files like SharePoint & Project Server CU update files, so in this case, you must add only one “exe” file in this folder then run the script, Once it finished, you should remove the old “exe” file then add the other one to get it patched.

  • Copy the patch file in the same folder as shown below
SharePoint Cumulative Update takes a long time to install
  • Run SharePoint Management Shell as administrator.
Run CA as Adminstrator
  • Locate the created folder location path.
  • Type patchit.ps1 > Click Enter.
SharePoint Cumulative Update takes a long time to install
SharePoint Cumulative Update takes long time to install
  • Don’t Close the SharePoint Management Shell until the installation is completed.
The SharePoint Cumulative Update installation is completed

Note: After Clicking OK, The Patch automatically will restart stopped services again.


Conclusion

In conclusion, we have provided a PowerShell script to accelerate the patching process and avoid the SharePoint Cumulative Update takes long time to install issue that you may face in SharePoint.

Applies To

  • SharePoint 2016.
  • SharePoint 2013.
Reference

Why SharePoint 2013 Cumulative Update takes 5 hours to install?

See Also

The expected version of the product was not found on the system SharePoint 2013.

9 thoughts on “SharePoint 2013 Cumulative Update takes long time to install”

  1. hello,
    after running this script, a SharePoint configuration wizard is required in any case, right?
    If yes, so may we run this script on all SharePoint servers farm at the same time or we have to do it one by one?
    thank you

    1. Of course, it’s required to apply the installed updates, it’s recommended to start with the APP server that hosts the central administration.
      Yes, you can run the script at the same time.

  2. hello,
    after running this script, a sharepoint configuration wizard is required, right?
    If yes, so may we run this script on all sharepoint servers farm at the same time or we have to do it one by one?
    thank you

    1. after running this script, a sharepoint configuration wizard is required, right?
      – Sure, you should run the config wizard to apply the installed updates.
      may we run this script on all sharepoint servers farm at the same time or we have to do it one by one?
      – Yes

  3. Hey, its good to see its successful. But, even for me as well. But I am unable to run the PS config wizard. Its failing at step-5. can you help me…

    Failed to upgrade SharePoint Products.

    An exception of type System.DirectoryServices.DirectoryServicesCOMException was
    thrown. Additional exception information: The service cannot be started, either
    because it is disabled or because it has no enabled devices associated with it.

    Total number of configuration settings run: 3
    Total number of successful configuration settings: 2
    Total number of unsuccessful configuration settings: 1
    Successfully stopped the configuration of SharePoint Products.
    Configuration of SharePoint Products failed. Configuration must be performed be
    fore you use SharePoint Products. For further details, see the diagnostic log l
    ocated at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\1
    5\LOGS\PSCDiagnostics_3_28_2016_6_42_10_771_632310512.log and the application ev
    ent log.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top