Execution Flow
Synopsis
Read-only preflight for the migration of an AlwaysOn availability group to a new cluster by Distributed AG. An unreachable instance does not throw: it becomes a blocker with cause and remedy and the remaining checks of the other side still run. Every check carries a German and an English message and remedy, so the result can be shown directly in the migration wizard.
Beyond the basics the function checks what makes seeding fail late: TDE certificates on the target (same thumbprint), the seeding mode of every target replica, earlier failed seeding runs, the free space of the log volumes on the source and FILESTREAM or In-Memory files. With -SeedingMode Manual the automatic-seeding checks are skipped and the backup path is checked instead. CREATE ANY DATABASE cannot be queried; with more than one target replica the function therefore always warns and names the command to run on the other replicas.
Syntax
Test-sqmDistributedAgMigrationPrerequisite -SourceInstance <String> -SourceAgName <String> -TargetInstance <String> -TargetAgName <String> [-SqlCredential <PSCredential>] [-DistributedAgName <String>] # default: Source_Target [-SourceFqdn <String>] [-TargetFqdn <String>] [-EndpointPort <Int32>] # default 5022 [-SeedingMode Automatic|Manual] [-BackupPath <String>]
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| -SourceInstance | String | , | Instance (node or listener) of the source. It has to host the PRIMARY of the source AG. |
| -SourceAgName | String | , | Name of the source AG. |
| -TargetInstance | String | , | Instance of the new cluster. It has to host the PRIMARY of the target AG. |
| -TargetAgName | String | , | Name of the target AG. It has to exist already. |
| -SqlCredential | PSCredential | , | Optional credential for both sides. |
| -DistributedAgName | String | <Source>_<Target> | Planned name of the Distributed AG. Used for the name-conflict check. |
| -SourceFqdn / -TargetFqdn | String | , | FQDNs for LISTENER_URL. When given, DNS resolution and the TCP port are tested from this machine. |
| -EndpointPort | Int32 | 5022 | Expected endpoint port (1024 to 65535). A different actual port is a warning. |
| -SeedingMode | String | Automatic | Automatic or Manual. Manual additionally checks the backup path. |
| -BackupPath | String | , | Backup path for manual seeding. A UNC share that both SQL service accounts can use is recommended. |
Return Value
| Property | Description |
|---|---|
| Checks | All checks with Id, Category/CategoryEn, Name/NameEn, Severity (Blocker or Warning), Status (Pass, Fail, Warn), MessageDe/MessageEn and RemedyDe/RemedyEn. |
| Blockers / Warnings | The failed and the warned checks. |
| Passed | Number of passed checks. |
| CanProceed | $true only when no blocker failed. |
| SourceDatabases | Names of the databases in the source AG (used by the wizard for the plan). |
| DistributedAgName, Timestamp | Planned name and time of the check. |
Examples
Example 1, Run the checks
Test-sqmDistributedAgMigrationPrerequisite -SourceInstance "SQL01" -SourceAgName "ProdAG" `
-TargetInstance "NEW01" -TargetAgName "ProdAG_NEW"Example 2, With FQDNs and the endpoint port, show only problems
$r = Test-sqmDistributedAgMigrationPrerequisite -SourceInstance "SQL01" -SourceAgName "ProdAG" `
-TargetInstance "NEW01" -TargetAgName "ProdAG_NEW" `
-SourceFqdn "sql01.corp.local" -TargetFqdn "new01.corp.local" -EndpointPort 5022
$r.Checks | Where-Object Status -ne 'Pass' | Format-Table Status, NameEn, MessageEn, RemedyEn -WrapExample 3, Manual seeding with a backup share
Test-sqmDistributedAgMigrationPrerequisite -SourceInstance "SQL01" -SourceAgName "ProdAG" `
-TargetInstance "NEW01" -TargetAgName "ProdAG_NEW" `
-SeedingMode Manual -BackupPath "\\fileserver\sqlbackup"Example 4, Use the result in a script
$r = Test-sqmDistributedAgMigrationPrerequisite @params
if (-not $r.CanProceed) { $r.Blockers | ForEach-Object { Write-Warning "$($_.NameEn): $($_.MessageEn)" } }