< Back

Set-DbaAgReplica

Mon Jan 13, 2020 5:30 pm

NAME Set-DbaAgReplica



SYNOPSIS

Sets the properties for a replica to an availability group on a SQL Server instance.





SYNTAX

Set-DbaAgReplica [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-AvailabilityGroup] <String>] [[-Replica] <String>] [[-AvailabilityMode] <String>]

[[-FailoverMode] <String>] [[-BackupPriority] <Int>] [[-ConnectionModeInPrimaryRole] <String>]

[[-ConnectionModeInSecondaryRole] <String>] [[-SeedingMode] <String>] [[-SessionTimeout] <Int>] [[-EndpointUrl]

<String>] [[-ReadonlyRoutingConnectionUrl] <String>] [[-InputObject]

<Microsoft.SqlServer.Management.Smo.AvailabilityReplica>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Sets the properties for a replica to an availability group on a SQL Server instance.



Automatically creates a database mirroring endpoint if required.





PARAMETERS

-AvailabilityGroup [<String>]

The availability group of the replica.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-AvailabilityMode [<String>]

Sets the availability mode of the availability group replica. Options are: AsynchronousCommit and

SynchronousCommit. SynchronousCommit is default.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-BackupPriority [<Int>]

Sets the backup priority availability group replica. Default is 50.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ConnectionModeInPrimaryRole [<String>]

Sets the connection intent modes of an Availability Replica in primary role.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ConnectionModeInSecondaryRole [<String>]

Sets the connection modes of an Availability Replica in secondary role.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EndpointUrl [<String>]

The endpoint URL.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-FailoverMode [<String>]

Sets the failover mode of the availability group replica. Options are Automatic and Manual.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<Microsoft.SqlServer.Management.Smo.AvailabilityReplica>]

Enables piping from Get-DbaAgReplica.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ReadonlyRoutingConnectionUrl [<String>]

Sets the read only routing connection url for the availability replica.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Replica [<String>]

The replicas to modify.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SeedingMode [<String>]

Specifies how the secondary replica will be initially seeded.



Automatic enables direct seeding. This method will seed the secondary replica over the network. This method

does not require you to backup and restore a copy of the primary database on the replica.



Manual requires you to create a backup of the database on the primary replica and manually restore that backup

on the secondary replica.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SessionTimeout [<Int>]

How many seconds an availability replica waits for a ping response from a connected replica before considering

the connection to have failed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: AvailabilityGroup, HA, AG

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-DbaAgReplica -SqlInstance sql2016 -Replica sql2016 -AvailabilityGroup SharePoint -BackupPriority 5000



Sets the backup priority to 5000 for the sql2016 replica for the SharePoint availability group on sql2016

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaAgReplica -SqlInstance sql2016 | Out-GridView -Passthru | Set-DbaAgReplica -BackupPriority 5000



Sets the backup priority to 5000 for the selected availability groups.



RELATED LINKS

https://dbatools.io/Set-DbaAgReplica