Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
SharePoint Patching
If you are a SharePoint admin and you have been asked to patch a SharePoint farm, then you need to follow below steps:
Here's a patch for your UAT or test environment before installing the patch on production and try to validate the farm post CU installation. Once everything is confirmed and running fine on UAT and test environment then move to production. Never ever try to patch the SharePoint production farm directly.
Steps:
Before proceeding further we would like to say there is no difference in version of patches for Foundation or Enterprise or standard version. Single patch will fix all the issues of all version.
First of all, make sure you have installed the correct SP1. As per Microsoft, there are two SP1 but one is faulty and another one is correct one KB 2880552.
Once after the SP1 confirmation, you need to check there should not be any orphan feature. To check orphan feature you can use below Power Shell command:
Get-SPFeature | ? { $_.Scope -eq $null }
If this command returns any feature then you have to delete all the orphaned features and use below PowerShell:
$feature = Get-SPFeature | ? { $_.DisplayName -eq "My_Orphane_Feature" }
$feature.Delete()
- Once after deleting the orphan feature check for orphan database if any:
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{Add-PSSnapin Microsoft.SharePoint.Powershell}
$CDBs = Get-SPContentDatabase
ForEach ($CDB in $CDBs)
{
Write-Host "Detecting Orphans for " $CDB.Name
$CDB.Repair($false)
}
If there is any orphan database, you have to repair the database otherwise it will create issue while running configuration wizard:
$CDB = Get-SPContentDatabase -Identity "Orphan DB Name"
$CDB.Repair($true)
Run the below PowerShell:
net stop SPAdminV4
Start-SPAdminJob
net start SPAdminV4
Once after fixing the database errors, download the SharePoint patch and install it on SharePoint server.
Please look for the required Cumulative Update which you want to install and then download it from the Microsoft website. For instance, if you’re planning to install the October 2016 CU for SharePoint Server 2013 in your farm then just search as “October 2016 CU for SharePoint server 2013 “and you will get the link to download the package.
- Back Up:
This step is the most important and critical step. Before starting patching activity you have to make sure that certain things to be backed up:
i) Take a SharePoint farm backup using the backup option in Central Administration site. Below PowerShell also can be used to take the backup:
Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} [-Verbose]
ii) Schedule Sharepoint farm backup, prior to CU installation hoping that no changes will be made to SharePoint farm post that.
iii) Take the necessary IIS backups.
iv) Also, take the backup of the web.config file in IIS.
v) Take the backup of all the WSp files deployed in the farm
$farm = Get-SPFarm
$file = $farm.Solutions.Item(“solution.wsp”).SolutionFile
$file.SaveAs(“c:\Solution.wsp”)
vi) Finally, once all the backups have been taken the most important things to do is take the snapshot of all the SharePoint server and SQL server too.
- Pre-Installation Checklist:
Before starting patching you need to make sure there should not be any crawl running behind the scene. You can check at below path:
Central Administration-> Application Management -> Manage Service Application -> Search service
and at Search Administration page check Crawl rate should be zero. You can also check at content source page: All content sources should be in Idle state.
You can also use below PowerShell command to stop the services:
########################
##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
Now you can install the patch. Right-click on patch and click on Run as administration. Accept end user license and it will start to install the patch it will take around 20-30 minutes to get it installed in your machine.
Post installation it may prompt to reboot the system click Yes. Once after the installation is complete , go to Control Panel and verify whether the package has been installed or not.
For multi server Environment Order of installation:
If you have a three tier farm topology then it's suggested to install SharePointnt patch first on WFE server and then app server. As App servers are very critical. Ensure that WFE is taken out of the load balancer pool so that its not serving user traffic and go ahead and install the CU and reboot the server. Once the Server comes back online verify patch is installed successfully and central admin site is accessible.Run Configuration Wizard:
You can run the configuraion wizard from PowerShell or from UI.
PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures
Sometimes this powershell may stuck at 2nd step then you can restart the SharePoint timer service and SharePoint administration service from Services.msc.
If the PowerShell stuck at fifth step then you can clear config cache which is located at:
%SystemDrive%\ProgramData\Microsoft\SharePoint\Config\GUID
These are the below steps to clean the cache:
i) Stop the Timer service. To do this, follow these steps:
ii) Click Start, point to Administrative Tools, and then click Services.
iii) Right-click SharePoint 2010 Timer, and then click Stop.
iv) Close the Services console.
v) On the computer that is running Microsoft SharePoint Server 2010 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
vi) In Windows Explorer, locate and then double-click the following folder:
%SystemDrive%\ProgramData\Microsoft\SharePoint\Config\GUID
Notes
vii) The %SystemDrive% system variable specifies the letter of the drive on which Windows is installed. By default, Windows is installed on drive C.
viii) The GUID placeholder specifies the GUID folder. There may be more than one of these.
ix) The ProgramData folder may be hidden. To view the hidden folder, follow these steps:
x) On the Tools menu, click Folder Options.
Click the View tab.
xi) In the Advanced settings list, click Show hidden files and folders under Hidden files and folders, and then click OK.
xii) You can also simply type this directly in the path if you do not want to show hidden files and folders.
xiii) Back up the Cache.ini file. (Make a copy of it. DO NOT DELETE THIS FILE, Only the XML files in the next step)
xiv) Delete all the XML configuration files in the GUID folder (DO NOTE DELETE THE FOLDER). Do this so that you can verify that the GUID folders content is replaced by new XML configuration files when the cache is rebuilt.
xv) Note When you empty the configuration cache in the GUID folder, make sure that you do NOT delete the GUID folder and the Cache.ini file that is located in the GUID folder.
xvi) Double-click the Cache.ini file.
xvii) On the Edit menu, click Select All.
xviii) On the Edit menu, click Delete.
Type 1, and then click Save on the File menu. (Basically when you are done, the only text in the config.ini file should be the number 1)
On the File menu, click Exit.
Start the Timer service. To do this, follow these steps:
Click Start, point to Administrative Tools, and then click Services.
Right-click SharePoint 2010 Timer, and then click Start.
Close the Services console.
If Configuration Wizard failed with any error the n check upgrade error log file and troubleshoot the error. If it is successfully completed then check as per post installation Steps:
- Post Installation Steps:
Verify all the SharePoint and IIS services are up and running. If not, start them.
Go to IIS Manager and verify application pools and sites are in started/running state.
Open CA and the web applications and make sure they are opening fine
Go to “Manage servers in the farm” section in CA and check for the version number on Configuration database version and make sure it’s showing the version number correctly. Ex: For January 2016 CU, it should show the version number as 15.0.4787.1000
You can also check the upgrade status by below powershell:
stsadm -o localupgradestatus
Once you are sure about patch installation start all the service which you stopped before patching. You can use below powershell:
##################
##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"