· Uwe Janke
Commands / Compare-sqmConfigBaseline

Compare-sqmConfigBaseline

Configuration sqmSQLTool v1.9.202.0+ · Compare
Config drift check. Compares all options from sys.configurations (active value and pending changes) and the global trace flags against a baseline saved with Save-sqmConfigBaseline.

Two modes: live (-SqlInstance is read now) and file (-ComparePath checks two baselines against each other, for example before and after a patch). The result has one row per difference (Category, Setting, SourceValue = baseline, TargetValue = compared state, Status, DriftType). No drift returns nothing and the report says so.

Drift types: value_in_use differs, pending (RECONFIGURE) or pending (restart) when the configured value differs from the active one on only one side, missing for an option that exists on one side only, and trace flag. Security-relevant options (xp_cmdshell, Ole Automation Procedures, Ad Hoc Distributed Queries, clr enabled, clr strict security, cross db ownership chaining, scan for startup procs, external scripts enabled) are Critical, everything else Warning.

Options that exist in only one of two different major versions are not drift (a warning notes the version difference). version high part of SQL Server, version low part of SQL Server and show advanced options are always ignored.

Parameters

ParameterTypeRequiredDefaultNotes
-BaselinePathstringRequired—Baseline JSON from Save-sqmConfigBaseline (reference).
-SqlInstancestringRequired—Live mode: instance to check. Required in live mode.
-SqlCredentialPSCredentialOptional—Optional SQL login (live mode).
-ComparePathstringRequired—File mode: second baseline to check against the first. Required in file mode.
-IgnoreOptionstring[]Optional@()Additional option names to skip, wildcards allowed.
-OutputPathstringOptional<module output path>\ConfigBaselineCompareFolder for the TXT and HTML report.
-NoOpenswitchSwitch$falseDo not open the report.
-NoReportswitchSwitch$falseReturn the rows only, write no report.
-EnableExceptionswitchSwitch$falseThrow instead of reporting an error and returning $null.

Execution Flow

START Load baseline JSON Meta, options, trace flags Read live instance or load second baseline Get-sqmConfigOptionSet or JSON file Compare option sets value_in_use, pending state, missing options, trace flags Write TXT and HTML report Critical / Warning counts, or "no drift" Return difference rows Category, Setting, SourceValue, TargetValue, Status, DriftType DONE

Examples

Check an instance against a baseline
Compare-sqmConfigBaseline -BaselinePath "D:\Baselines\ConfigBaseline_SQL01_v15_20261101_090000.json" -SqlInstance "SQL02"
Compare two baselines, for example before and after a patch
Compare-sqmConfigBaseline -BaselinePath $beforePatch -ComparePath $afterPatch -NoOpen
Skip options you expect to differ
Compare-sqmConfigBaseline -BaselinePath $b -SqlInstance "SQL02" -IgnoreOption "max server memory*","backup*"