Execution Flow
The network check (Check 5) is optional and only runs when
-TargetInstance is supplied — with it present, a failed network test still only costs one check out of five toward the score, so a firewall-blocked secondary doesn't automatically read as NOT_READY unless the DB-level checks are also unhealthy. This is a pre-flight readiness assessment, not a failover trigger — pair it with Invoke-sqmDistributedFailover.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -SqlInstance | String | Optional | Primary SQL Server instance. Default: local computer name. Pipeline-capable. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential for the connection. |
| -TargetInstance | String | Optional | Secondary SQL Server instance for the optional network reachability test. |
| -OutputPath | String | Optional | Output directory for report files. Default: C:\System\WinSrvLog\MSSQL. |
| -EnableException | Switch | Optional | Throw exceptions immediately instead of returning a Score of 0. |
Return Value
Returns a single PSCustomObject with: SqlInstance, Timestamp, ReadinessScore (0–100), Status (READY, MOSTLY_READY, or NOT_READY), CheckResults (array of per-check Check/Result/Details objects).
Examples
Example 1 — Check readiness including network test to the DR side
Test-sqmDistributedAgReadiness -SqlInstance "SQL01" -TargetInstance "DR-SQL01"Example 2 — Database-level checks only, no network test
Test-sqmDistributedAgReadiness -SqlInstance "SQL01"Example 3 — Gate a failover script on full readiness
$r = Test-sqmDistributedAgReadiness -SqlInstance "SQL01" -TargetInstance "DR-SQL01"
if ($r.Status -eq 'READY') { Invoke-sqmDistributedFailover -SqlInstance "SQL01" }