dbatools

Enable-DbaAgHadr

View Source
Shawn Melton (@wsmelton), wsmelton.github.io
Windows, Linux, macOS

Synopsis

Enables HADR service setting on SQL Server instances to allow Availability Group creation.

Description

Configures the High Availability Disaster Recovery (HADR) service setting on SQL Server instances, which is a required prerequisite before you can create Availability Groups. This setting must be enabled at the instance level and requires a service restart to take effect. Use this command when preparing SQL Server instances for Availability Group participation after your Windows Server Failover Cluster is already configured.

Syntax

Enable-DbaAgHadr
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-Credential] <PSCredential>]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Enable-DbaAgHadr -SqlInstance sql2016

Sets Hadr service to enabled for the instance sql2016 but changes will not be applied until the next time the server restarts.

Example: 2
PS C:\> Enable-DbaAgHadr -SqlInstance sql2016 -Force

Sets Hadr service to enabled for the instance sql2016, and restart the service to apply the change.

Example: 3
PS C:\> Enable-DbaAgHadr -SqlInstance sql2012\dev1 -Force

Sets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (ByValue)
Default Value

Optional Parameters

-Credential

Windows credential object used to connect to the target server with different authentication context.
Required when the current user lacks administrative privileges on the SQL Server host or when connecting across domain boundaries.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Force

Automatically restarts the SQL Server Database Engine and SQL Server Agent services to immediately apply the HADR setting change.
Without this parameter, the HADR setting change requires a manual service restart before Availability Groups can be created.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

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

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

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

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value