DB Servers Hotfixes best practices report by SPDocKit determines whether all SQL servers supporting the SharePoint farm are running on the same patch level.
A SharePoint farm may utilize one or more SQL servers in various configurations to store configuration, content, and service application databases. This check determines whether all SQL servers supporting the SharePoint farm are running on the same patch level.
Explanation
All components in a SharePoint environment should be on the same patch level in order to provide maximum compatibility, stability, and supportability. This also applies to SQL servers.
Solution
Check all SQL servers in the SharePoint environment. Make sure that all SQL servers are running on the same patch level and that they are running on the minimum required patch level to support the SharePoint version you are running. In addition, verify that all servers are running the same Windows Server hotfixes.
To verify installed Windows and SQL Server updates, start Control Panel, go to Programs > Programs and Features and click View installed updates.
You can use this script:
param( [ValidateSet("Disable","Quick","Detailed")] [string]$WindowsUpdateCheck="Quick")functionGet-SPServerList{ $spServerList=@() $serverList =Get-SPServer foreach ($server in $serverList) {if ($server.Role -ne [Microsoft.SharePoint.Administration.SPServerRole]::Invalid) { $spServerList += $server.Address } }return $spServerList}functionGet-WinUpdateLastInstalledHotfixDate([string]$serverName){ $result =Get-HotFix-ComputerName $serverName -ErrorActionSilentlyContinue|Measure-ObjectInstalledOn-Maximumif (![string]::IsNullOrEmpty($result)) { $result = $result.Maximum.ToString("yyyy-MM-dd hh:mm:ss") }return $result}functionGet-WinUpdateLastCheckDate([string]$serverName){ $result =Invoke-Command-ComputerName $serverName -ScriptBlock{Get-ItemProperty-Path'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsDetect'-NameLastSuccessTime-ErrorActionSilentlyContinue|select -ExpandProperty LastSuccessTime}return $result }functionGet-WinUpdateLastInstallDate([string]$serverName){ $result =Invoke-Command-ComputerName $serverName -ScriptBlock{Get-ItemProperty-Path'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateResultsInstall'-NameLastSuccessTime-ErrorActionSilentlyContinue|select -ExpandProperty LastSuccessTime}return $result}functionGet-AvailableWindowsUpdatesCount([string]$serverName){ $numUpdates =Invoke-Command-ComputerName $serverName -ScriptBlock{$Searcher =New-Object-ComObjectMicrosoft.Update.Searcher; $results = $searcher.search("Type='software' AND IsInstalled = 0 AND IsHidden = 0"); $results.Updates.Count}-ErrorActionSilentlyContinueif ([string]::IsNullOrEmpty($numUpdates)) { $numUpdates =-1 }return $numUpdates}functionGet-SPFarmVersion{return (Get-SPFarm).BuildVersion.ToString()}# based on the script by Stefan Goßner# for more information, please visit http://blogs.technet.com/b/stefan_gossner/archive/2015/04/20/powershell-script-to-display-version-info-for-sharepoint-product-and-language-packs.aspxfunctionGet-SPProductsBuild([string]$serverName){ $farmVersion = (Get-SPFarm).BuildVersion.ToString()# Get SharePoint Products and language packs $programs =Invoke-Command-ComputerName $serverName -ScriptBlock{$regLoc =Get-ChildItem"HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall" ; $RegLoc |where-object{ $_.PsPath-like"*Office*"}| foreach {Get-ItemProperty $_.PsPath}} $consoleForegroundColor = [console]::ForegroundColor $Programs | foreach { $_ |SelectDisplayName,DisplayVersion| foreach { if ( $_.DisplayVersion.Trim() -ne $farmVersion ) { [console]::ForegroundColor="Red"}else{[console]::ForegroundColor=$consoleForegroundColor} $_ }; } [console]::ForegroundColor= $consoleForegroundColor}functionCheck-WindowsUpdatesDetailed([string]$serverName){Write-Host"Available Windows Updates: "-NoNewLine $numWU =Get-AvailableWindowsUpdatesCount $serverNameif ($numWU -gt 0) { $fc ="Yellow" }else { $fc ="Green" }if ($numWU -eq -1) { $fc ="Red" $numWU ="Failed to connect" }Write-Host $numWU -ForegroundColor $fc}functionCheck-WindowsUpdatesQuick([string]$serverName){ $wuLastCheck =Get-WinUpdateLastCheckDate $serverName $wuLastInstall =Get-WinUpdateLastInstallDate $serverName $fcC = $fcI = [console]::ForegroundColorif ([string]::IsNullOrEmpty($wuLastCheck)) { $wuLastCheck ="Unknown" $fcC ="Red" }if ([string]::IsNullOrEmpty($wuLastInstall)) { $wuLastInstall =Get-WinUpdateLastInstalledHotfixDate $serverNameif ([string]::IsNullOrEmpty($wuLastInstall)) { $fcI ="Red" $wuLastInstall ="Unknown" } }Write-Host"`tLastWindowsUpdatecheck: " -NoNewLine Write-Host "$wuLastCheck" -ForegroundColor $fcC Write-Host "`t Last Windows Update installation: "-NoNewLineWrite-Host"$wuLastInstall"-ForegroundColor $fcI}functionGet-SPServerNeedingUpgrade{ $serverList =Get-SPServer|Where{ ($_.NeedsUpgrade -eq $TRUE) -and ($_.Role -ne [Microsoft.SharePoint.Administration.SPServerRole]::Invalid)}if ([string]::IsNullOrEmpty($serverList)) {Write-Host"None."-ForegroundColorGreen }else { $serverList |ft-a }}### Main$spServerList = Get-SPServerListWrite-Host"SharePoint farm build $((Get-SPFarm).BuildVersion.ToString())"-ForegroundColorYellowWrite-Host""switch ($WindowsUpdateCheck){"Disable"{Write-Host"Skipping Windows Update check"-ForegroundColorYellow}"Quick"{Write-Host"Last Windows Update check and installation time will be retrieved."-ForegroundColorYellow}"Detailed"{Write-Host"Detailed Windows Update check will be performed. This may take a long time."-ForegroundColorYellow}}foreach ($server in $spServerList){Write-Host"================================================="-ForegroundColorGreenWrite-Host"Server: $server"-ForegroundColorGreenWrite-Host"================================================="-ForegroundColorGreenswitch ($WindowsUpdateCheck) {"Disable"{}"Quick"{Check-WindowsUpdatesQuick $server }"Detailed"{Check-WindowsUpdatesQuick $server; Check-WindowsUpdatesDetailed $server } }Write-Host""Write-Host"Installed binaries:"Get-SPProductsBuild $serverWrite-Host""}Write-Host"Following SharePoint servers must be upgraded via PSCONFIG: "-ForegroundColorYellowGet-SPServerNeedingUpgrade
Additional information
Additional information can be found in the following TechNet articles: