Export-sqmDatabaseSettings
SQL ConfigurationsqmSQLTool v1.8.2+ · ExportJSON + HTML Export ✅ -WhatIf supported
sys.databases; no need to connect into each database individually. System databases (master/model/msdb/tempdb) are excluded by default. The counterpart, Import-sqmDatabaseSettings, re-applies a saved snapshot via ALTER DATABASE.Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Required | , | Source SQL Server instance. |
| -SqlCredential | PSCredential | Optional | , | Optional alternative credentials. |
| -Database | string[] | Optional | , | Restrict the export to these database names (wildcards allowed). Without this, every database is exported (subject to the two switches below). |
| -ExcludeDatabase | string[] | Optional | , | Additional database names to exclude (wildcards allowed). |
| -IncludeSystemDatabases | switch | Switch | $false | When set, master/model/msdb/tempdb are included in the export. |
| -OutputPath | string | Required | , | A full file path, or an existing/creatable directory - in the latter case the file is auto-named DatabaseSettings_<Instance>_<timestamp>.json. An HTML report with the same base name (.html) is written alongside it. |
| -NoOpen | switch | Switch | $false | Suppress automatically opening the generated HTML report. |
| -EnableException | switch | Switch | $false | Throw exceptions immediately instead of returning a Failed result object. |
| -WhatIf / -Confirm | switch | Optional | , | ShouldProcess guard on the file-writing step. Shows what would be written (path, database count) without creating any file. |
Execution Flow
Examples
Export the Options settings of every user database
Export-sqmDatabaseSettings -SqlInstance 'SQL01' -OutputPath 'C:\Backups\SQLSnapshots'
Export a single database's settings to an explicit file
Export-sqmDatabaseSettings -SqlInstance 'SQL01' -Database 'SalesDB' -OutputPath 'C:\Backups\SalesDB_Options.json'
Preview what would be exported, without writing anything
Export-sqmDatabaseSettings -SqlInstance 'SQL01' -OutputPath 'C:\Backups\SQLSnapshots' -WhatIf