Execution Flow
Synopsis
Queries all AGs on the given SQL Server instance via dbatools and DMVs. For each AG, all replica/database rows are evaluated: redo queue, send queue, synchronization state, connection state, and suspend status determine an OverallStatus (OK / Warning / Critical). AutoSeed progress is shown for SQL Server 2016+. Reports are saved as TXT, CSV, and a filterable/sortable interactive HTML dashboard.
Requires dbatools and VIEW SERVER STATE on the target instance. The SQL Server major version is auto-detected to select the correct AutoSeed DMV query (SQL 2019+ adds
group_database_id and size columns).Syntax
Get-sqmAlwaysOnHealthReport [-SqlInstance <String[]>] # pipeline [-SqlCredential <PSCredential>] [-MaxRedoQueueMB <Int>] [-MaxSendQueueMB <Int>] [-OutputPath <String>] [-OutputHtml] [-ContinueOnError] [-EnableException]
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| -SqlInstance | String[] | $env:COMPUTERNAME | SQL Server instance(s) to query. Pipeline-capable. |
| -SqlCredential | PSCredential | — | Credential for the SQL connection. |
| -MaxRedoQueueMB | Int | 100 | Redo queue warning threshold in MB (secondary replicas). |
| -MaxSendQueueMB | Int | 50 | Send queue warning threshold in MB. |
| -OutputPath | String | C:\System\WinSrvLog\MSSQL | Directory for TXT, CSV, and HTML report files. |
| -OutputHtml | Switch | $true | Generate an interactive HTML dashboard in addition to TXT/CSV. |
| -ContinueOnError | Switch | false | Continue with the next instance on error. |
| -EnableException | Switch | false | Throw terminating exceptions. |
OverallStatus Logic
| Status | Condition |
|---|---|
| Critical | DbSyncState not in (SYNCHRONIZED/SYNCHRONIZING) OR ConnectionState ≠ CONNECTED OR IsSuspended = true. |
| Warning | RedoQueueMB > MaxRedoQueueMB (secondary) OR SendQueueMB > MaxSendQueueMB. Also: any AutoSeed in progress. |
| OK | All checks passed. |
Examples
# Health report for local instance Get-sqmAlwaysOnHealthReport # Custom thresholds and output path Get-sqmAlwaysOnHealthReport -SqlInstance "SQL01" -MaxRedoQueueMB 200 -OutputPath "D:\Reports" # Multiple instances via pipeline "SQL01","SQL02" | Get-sqmAlwaysOnHealthReport -ContinueOnError