Commands / Invoke-sqmSqlAlwaysOnAutoSeeding
Invoke-sqmSqlAlwaysOnAutoSeeding
Always OnsqmSQLTool v1.8.2+ · Configuration⚠ Requires SQL 2016+  ✓ Prerequisites
Enables Automatic Seeding on an Always On Availability Group (SQL Server 2016+). Validates prerequisites: replica disk space, database file path availability, network connectivity, and permission grants on both primary and secondary replicas. Automatically configures directed network paths for seeding transfers.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringRequiredPrimary replica instance.
-SqlCredentialPSCredentialOptionalCredentials for primary and replicas.
-AvailabilityGroupstringRequiredName of the availability group.
-SqlVersionintOptionalAuto-detectSQL Server version (2016, 2017, 2019, 2022). Auto-detected if omitted.
-ValidateOnlyswitchSwitch$falseCheck prerequisites without making changes.
-EnableExceptionswitchSwitch$falseRe-throw exceptions immediately.
-WhatIf / -ConfirmswitchOptionalShouldProcess (ConfirmImpact: High) guards configuration changes.

Execution Flow

START dbatools available? NO throw: dbatools not found YES Connect to primary replica (-SqlInstance) Verify primary is online and holds AG Verify SQL Server version ≥ 2016 AutoSeeding is only available in SQL 2016+ If older: throw error Get AG info: replicas, seeding mode, database paths Check current AutomaticSeeding state (Automatic/Manual/Disabled) Read database file paths from primary PREREQUISITES CHECK (per replica) • Replicas are SYNCHRONIZED (or check connectivity) • DB file paths exist and have sufficient disk space • SQL Server service account has write permissions • Network paths (directed seeding) are reachable All checks passed? NO return: prereq failed details YES -ValidateOnly? YES Return: validated (no change) NO ShouldProcess? (ConfirmImpact: High) NO WhatIf: show plan continue YES ALTER AVAILABILITY GROUP ... SEEDING_MODE = AUTOMATIC Enable automatic seeding on AG Return [PSCustomObject] seeding configuration result AvailabilityGroup, SeedingMode, Status, Prerequisites DONE

Examples

Validate AutoSeeding prerequisites (no changes)
Invoke-sqmSqlAlwaysOnAutoSeeding -SqlInstance "SQL01" -AvailabilityGroup "AG_Prod" -ValidateOnly
Enable AutoSeeding on AG with -WhatIf
Invoke-sqmSqlAlwaysOnAutoSeeding -SqlInstance "SQL01" -AvailabilityGroup "AG_Prod" -WhatIf