Complete-sqmListenerMigration
Always On
sqmSQLTool v1.8.2+ · Maintenance
✓ -WhatIf supported ⚠ ConfirmImpact: High
The function: verifies the AG exists, captures database state before, performs a soft DNS resolution check on the new listener, calls
ALTER AVAILABILITY GROUP … ADD LISTENER, waits 5 seconds, verifies the listener was registered, rechecks database state after, and writes a TXT completion report.
Returns a
[PSCustomObject] with Status = 'SUCCESS' (all DBs online), 'PARTIAL_SUCCESS' (some DBs still in recovery), or 'FAILED' (exception). A 'CANCELLED' result is returned when -WhatIf is used.
Critical: Only run after the cluster team confirms the new listener cluster resource is ONLINE. Prepare phase:
Invoke-sqmListenerMigrationPrep.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Optional | $env:COMPUTERNAME | SQL Server instance hosting the AG (primary). |
| -AvailabilityGroupName | string | Required | — | Name of the Availability Group to which the listener is re-added. |
| -ListenerName | string | Required | — | DNS name of the new listener cluster resource. |
| -SqlCredential | PSCredential | Optional | — | Credential for the SQL Server connection. |
| -OutputPath | string | Optional | C:\System\WinSrvLog\MSSQL | Directory for the completion report. Created if missing. |
| -EnableException | switch | Switch | $false | Re-throw errors instead of returning a FAILED result object. |
| -WhatIf / -Confirm | switch | Optional | — | ShouldProcess with ConfirmImpact=High. -WhatIf skips the ALTER statement and returns Status='CANCELLED'. |
Execution Flow
Examples
Complete the listener migration for ProdAG (run after cluster team is done)
Complete-sqmListenerMigration `
-SqlInstance "SQL02" `
-AvailabilityGroupName "ProdAG" `
-ListenerName "PROD-SQL-Listener"
Dry-run: preview without altering the AG
Complete-sqmListenerMigration -SqlInstance "SQL02" -AvailabilityGroupName "ProdAG" -ListenerName "PROD-SQL-Listener" -WhatIf