· Uwe Janke
Commands / Save-sqmConfigBaseline

Save-sqmConfigBaseline

Configuration sqmSQLTool v1.9.202.0+ · Save
Saves a baseline of an instance: every option from sys.configurations (configured value, active value, is_dynamic, is_advanced) plus the global trace flags, with metadata (server, product version, capture time, label) as a JSON file.

Keep one baseline per major version (the major version is part of the file name) and check each instance only against the baseline of its version with Compare-sqmConfigBaseline.

Not captured: database options, startup parameters and settings that only exist through ALTER SERVER CONFIGURATION. Trace flags need VIEW SERVER STATE (SQL Server 2022 and later: VIEW SERVER PERFORMANCE STATE); without it they are left empty and skipped during the comparison.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringRequired—Instance to capture.
-SqlCredentialPSCredentialOptional—Optional SQL login.
-LabelstringOptional—Free text stored in the file, for example Standard 2019 or after patch day.
-OutputPathstringOptional<module output path>\ConfigBaselineTarget folder; created if missing.
-EnableExceptionswitchSwitch$falseThrow instead of logging and returning $null.

Execution Flow

START Read sys.configurations Invoke-DbaQuery: value, value_in_use, is_dynamic, is_advanced Read global trace flags DBCC TRACESTATUS(-1), skipped when not permitted Write JSON baseline ConfigBaseline_<server>_v<major>_<timestamp>.json Return summary object BaselinePath, ServerName, MajorVersion, OptionCount, TraceFlagCount DONE

Examples

Save a baseline with a label
Save-sqmConfigBaseline -SqlInstance "SQL01" -Label "Standard 2019"
Save into a shared folder and check another instance right away
$b = Save-sqmConfigBaseline -SqlInstance "SQL01" -OutputPath "D:\Baselines"
Compare-sqmConfigBaseline -BaselinePath $b.BaselinePath -SqlInstance "SQL02"