Set-SqlAvailabilityReplicaRoleToSecondary

Sets the Availability Group replica role to secondary.

Syntax

Set-SqlAvailabilityReplicaRoleToSecondary
   [[-Path] <String[]>]
   [-Script]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-SqlAvailabilityReplicaRoleToSecondary
   [-InputObject] <AvailabilityGroup[]>
   [-Script]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

On the SQL Server that hosts the primary replica for the primary availability group, sets the replica role to SECONDARY.

Examples

EXAMPLE 1: Shows how to set an availability group primary replica to SECONDARY role

PS C:\> CD 'SQLSERVER:\SQL\MYSERVER\MYINSTANCE\AvailabilityGroups\AG1'
PS SQLSERVER:\SQL\MYSERVER\MYINSTANCE\AvailabilityGroups\AG1> Set-SqlAvailabilityReplicaRoleToSecondary

This examples show how to set the primary replica of availability group AG1 on server MYSERVER (instance = MYINSTANCE) to SECONDARY role. The name of the availability is inferred from the context, i.e. the current location.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

Specifies the availability group, as an AvailabilityGroup object, that this cmdlet modifies.

Type:AvailabilityGroup[]
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Path

Specifies the path of the Availability Group to which the replica belongs. If you do not specify this parameter, this cmdlet uses current working location.

Type:String[]
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Script

Indicates that this cmdlet returns a Transact-SQL script that performs the task that this cmdlet performs.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Microsoft.SqlServer.Management.Smo.AvailabilityGroup[]