Commands / Invoke-sqmPatchAnalysis
Invoke-sqmPatchAnalysis
PerformancesqmSQLTool v1.8.2+ · Compliance🛠 Pipeline
Analyzes installed SQL Server patch level by reading the ProductVersion and comparing against an embedded reference table of known builds (CU/SP releases). Reports how many builds the instance lags behind the latest and provides a patch recommendation.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestring[]Optional$env:COMPUTERNAMEOne or more instances. Pipeline-capable.
-SqlCredentialPSCredentialOptionalCredentials for connections.
-OutputPathstringOptionalCSV report output path.
-EnableExceptionswitchOptional$falseRe-throw exceptions.

Execution Flow

START dbatools available? NO throw: dbatools not found YES Load embedded reference table (SQL builds) CU/SP version history per SQL edition (2016, 2017, 2019, 2022) foreach $instance in $SqlInstance Get-DbaInstance: ProductVersion, Edition, Build Example: 15.0.4249.3 = SQL 2019 + CU14 Match ProductVersion against reference table Find current CU level, get latest CU for same Edition Calculate lag: LatestCU - CurrentCU Lag = 0? (Current = Latest) NO Recommendation: Update to LatestCU YES Status: Current (no patch) If -OutputPath: export results to CSV Instance, Edition, CurrentCU, LatestCU, BuildsLagging, Recommendation Return [PSCustomObject] per instance Instance, Edition, Version, CurrentCU, LatestCU, Lag, Recommendation DONE

Examples

Check patch level for single instance
Invoke-sqmPatchAnalysis -SqlInstance "SQL01"
Pipeline multiple instances and export to CSV
"SQL01","SQL02","SQL03" | Invoke-sqmPatchAnalysis -OutputPath "D:\Reports\patches.csv"