Execution Flow
High-impact, cross-cluster operation. Step 3d (the secondary's
JOIN AVAILABILITY GROUP) is the critical action that actually establishes the distributed topology — omitting it leaves a one-sided, non-functional configuration. Always validate the primary AG is HEALTHY before proceeding.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| -PrimaryInstance | String | Required | Primary-side SQL instance (primary replica of the source AG). |
| -PrimaryAgName | String | Required | Name of the source (primary-side) Availability Group. |
| -SecondaryInstance | String | Required | Secondary-side SQL instance (primary replica of the target AG). |
| -SecondaryAgName | String | Required | Name of the target (secondary-side) Availability Group. |
| -PrimaryFqdn | String | Required | Fully qualified DNS name of the primary cluster's listener/endpoint. |
| -SecondaryFqdn | String | Required | Fully qualified DNS name of the secondary cluster's listener/endpoint. |
| -EndpointName | String | Optional | Mirroring endpoint name. Default: Hadr_endpoint. |
| -ServiceAccount | String | Optional | Service account to GRANT CONNECT ON ENDPOINT. |
| -SqlCredential | PSCredential | Optional | SQL authentication credential. |
| -EnableAutoSeed | Switch | Optional | Grants CREATE ANY DATABASE on the secondary for automatic seeding. |
| -SeedingMode | String | Optional | Automatic / Manual. Default: Automatic. |
| -OutputPath | String | Optional | Report output directory. Default: C:\System\WinSrvLog\MSSQL. |
| -EnableException | Switch | Optional | Throws terminating errors instead of returning a Failed status object. |
| -WhatIf / -Confirm | Switch | Optional | Standard ShouldProcess support (ConfirmImpact=High). |
Return Value
Returns a PSCustomObject with: Status (SUCCESS / FAILED), PrimaryInstance, PrimaryAgName, SecondaryInstance, SecondaryAgName, DistributedAgName, SeedingMode, Timestamp, Steps, ReportFile, NextSteps.
Examples
Example 1 — Join two clusters into a distributed AG
New-sqmDistributedAvailabilityGroup -PrimaryInstance "SQL01" -PrimaryAgName "AG-DC1" -SecondaryInstance "SQL11" -SecondaryAgName "AG-DC2" -PrimaryFqdn "ag-dc1-lst.firma.de" -SecondaryFqdn "ag-dc2-lst.firma.de"
Example 2 — Manual seeding with service account
New-sqmDistributedAvailabilityGroup -PrimaryInstance "SQL01" -PrimaryAgName "AG-DC1" -SecondaryInstance "SQL11" -SecondaryAgName "AG-DC2" -PrimaryFqdn "ag-dc1-lst.firma.de" -SecondaryFqdn "ag-dc2-lst.firma.de" -SeedingMode "Manual" -ServiceAccount "FIRMA\svc-sql"