commands

^

Set-DbaAvailabilityGroup

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Sets availability group properties on a SQL Server instance.

Description

Sets availability group properties on a SQL Server instance.

Syntax

Set-DbaAvailabilityGroup
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-AvailabilityGroup] <String[]>]
    [-AllAvailabilityGroups]
    [-DtcSupportEnabled]
    [[-ClusterType] <String>]
    [[-AutomatedBackupPreference] <String>]
    [[-FailureConditionLevel] <String>]
    [[-HealthCheckTimeout] <Int32>]
    [-BasicAvailabilityGroup]
    [-DatabaseHealthTrigger]
    [-IsDistributedAvailabilityGroup]
    [[-InputObject] <AvailabilityGroup[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaAvailabilityGroup -SqlInstance sql2016 | Set-DbaAvailabilityGroup -DtcSupportEnabled

Enables DTC for all availability groups on sql2016

Example: 2
PS C:\> Get-DbaAvailabilityGroup -SqlInstance sql2016 -AvailabilityGroup AG1 | Set-DbaAvailabilityGroup -DtcSupportEnabled:$false

Disables DTC support for the availability group AG1

Example: 3
PS C:\> Set-DbaAvailabilityGroup -SqlInstance sql2016 -AvailabilityGroup AG1 -DtcSupportEnabled:$false

Disables DTC support for the availability group AG1

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.

Alias
Required False
Pipeline false
Default Value
-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
-AvailabilityGroup

Only set specific availability group properties.

Alias
Required False
Pipeline false
Default Value
-AllAvailabilityGroups

Set properties for all availability group on an instance.

Alias
Required False
Pipeline false
Default Value False
-DtcSupportEnabled

Enables DtcSupport.

Alias
Required False
Pipeline false
Default Value False
-ClusterType

Cluster type of the Availability Group. Only supported in SQL Server 2017 and above. Options include: External, Wsfc or None.

Alias
Required False
Pipeline false
Default Value
Accepted Values External,Wsfc,None
-AutomatedBackupPreference

Specifies how replicas in the primary role are treated in the evaluation to pick the desired replica to perform a backup.

Alias
Required False
Pipeline false
Default Value
Accepted Values None,Primary,Secondary,SecondaryOnly
-FailureConditionLevel

Specifies the different conditions that can trigger an automatic failover in Availability Group.

Alias
Required False
Pipeline false
Default Value
Accepted Values OnAnyQualifiedFailureCondition,OnCriticalServerErrors,OnModerateServerErrors,OnServerDown,OnServerUnresponsive
-HealthCheckTimeout

This setting used to specify the length of time, in milliseconds, that the SQL Server resource DLL should wait for information returned by the sp_server_diagnostics stored procedure before reporting the Always On Failover Cluster Instance (FCI) as unresponsive. Changes that are made to the timeout settings are effective immediately and do not require a restart of the SQL Server resource. Defaults is 30000 (30 seconds).

Alias
Required False
Pipeline false
Default Value 0
-BasicAvailabilityGroup

Indicates whether the availability group is basic. Basic availability groups like pumpkin spice and uggs. https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/basic-availability-groups-always-on-availability-groups

Alias
Required False
Pipeline false
Default Value False
-DatabaseHealthTrigger

Indicates whether the availability group triggers the database health.

Alias
Required False
Pipeline false
Default Value False
-IsDistributedAvailabilityGroup

Indicates whether the availability group is distributed.

Alias
Required False
Pipeline false
Default Value False
-InputObject

Enables piping from Get-DbaAvailabilityGroup.

Alias
Required False
Pipeline true (ByValue)
Default Value
-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
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value

 

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