Reads a JSON snapshot previously exported by Export-sqmServerConfiguration and restores selected settings back to a SQL Server instance. Supports four categories: SpConfigure (sp_configure values), InstanceProperties (BackupDirectory, DefaultFile, DefaultLog), Services (StartMode via CIM), and DatabaseMail (info-only). Full -WhatIf support — no changes are applied during a dry run.
Execution Flow
Synopsis
The companion restore function for Export-sqmServerConfiguration. Reads the JSON snapshot file and processes up to four categories in order. For SpConfigure, each setting is compared against the current value — identical values are skipped with Status=Skipped; differing values are changed via $config.ConfigValue = …; Alter(). Instance properties are applied the same way via SMO. Service StartMode uses Invoke-CimMethod SetStartMode with the numeric mapping (Auto=2, Manual=3, Disabled=4). Database Mail profiles are always listed as Skipped with a note that manual restoration is required.
Use -WhatIf first to preview all changes. The output table shows OldValue vs. NewValue for every setting regardless of whether changes are applied.
Some sp_configure changes (e.g., max degree of parallelism) take effect immediately; others (e.g., max worker threads) require a SQL Server restart. Service changes require local administrator rights on the server.