commands

^

Test-DbaAvailabilityGroup

Author Andreas Jordan (@JordanOrdix), ordix.de
Availability Windows, Linux, macOS

 

Synopsis

Tests the health of an Availability Group and prerequisites for changing it.

Description

Tests the health of an Availability Group.

Can also test whether all prerequisites for Add-DbaAgDatabase are met.

Syntax

Test-DbaAvailabilityGroup
    [-SqlInstance] <DbaInstanceParameter>
    [-SqlCredential <PSCredential>] -AvailabilityGroup <String>
    [-Secondary <DbaInstanceParameter[]>]
    [-SecondarySqlCredential <PSCredential>]
    [-AddDatabase <String[]>]
    [-SeedingMode <String>]
    [-SharedPath <String>]
    [-UseLastBackup]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Test-DbaAvailabilityGroup -SqlInstance SQL2016 -AvailabilityGroup TestAG1

Test Availability Group TestAG1 with SQL2016 as the primary replica.

Example: 2
PS C:\> Test-DbaAvailabilityGroup -SqlInstance SQL2016 -AvailabilityGroup TestAG1 -AddDatabase AdventureWorks -SeedingMode Automatic

Test if database AdventureWorks can be added to the Availability Group TestAG1 with automatic seeding.

Required Parameters

-SqlInstance

The primary replica of the Availability Group.

Alias
Required True
Pipeline false
Default Value
-AvailabilityGroup

The name of the Availability Group to test.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Secondary

Not required - the command will figure this out. But use this parameter if secondary replicas listen on a non default port.

Alias
Required False
Pipeline false
Default Value
-SecondarySqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-AddDatabase

Test whether all prerequisites for Add-DbaAgDatabase to add these databases to the Availability Group are met. Use Secondary, SecondarySqlCredential, SeedingMode, SharedPath and UseLastBackup with the same values that will be used with Add-DbaAgDatabase later.

Alias
Required False
Pipeline false
Default Value
-SeedingMode

Only used when AddDatabase is used. See documentation at Add-DbaAgDatabase for more details.

Alias
Required False
Pipeline false
Default Value
Accepted Values Automatic,Manual
-SharedPath

Only used when AddDatabase is used. See documentation at Add-DbaAgDatabase for more details.

Alias
Required False
Pipeline false
Default Value
-UseLastBackup

Only used when AddDatabase is used. See documentation at Add-DbaAgDatabase for more details.

Alias
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False

 

Want to see the source code for this command? Check out Test-DbaAvailabilityGroup on GitHub.
Want to see the Bill Of Health for this command? Check out Test-DbaAvailabilityGroup.