Remove-SqlAvailabilityReplica

Removes a secondary availability replica.

Syntax

Remove-SqlAvailabilityReplica [-Path] <String[]> [-Script] [-InformationAction <ActionPreference>]
 [-InformationVariable <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-SqlAvailabilityReplica [-InputObject] <AvailabilityReplica[]> [-Script]
 [-InformationAction <ActionPreference>] [-InformationVariable <String>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

Description

The Remove-SqlAvailabilityReplica cmdlet removes the secondary replica that is specified by the InputObject or Path parameters. This cmdlet must be executed at the server instance that hosts the primary replica.

Examples

Example 1: Remove an availability replica

PS C:\> Remove-SqlAvailabilityReplica -Path "SQLSERVER:\SQL\PrimaryServer\InstanceName\AvailabilityGroups\MainAg\AvailabilityReplicas\MainReplica"

This command removes the availability replica named MainReplica from the availability group named MainAg. This command must be run on the server instance that hosts the primary replica of the availability group.

Example 2: Generate a Transact-SQL script that removes an availability replica

PS C:\> Remove-SqlAvailabilityReplica -Path "SQLSERVER:\SQL\PrimaryServer\InstanceName\AvailabilityGroups\MainAg\AvailabilityReplicas\MainReplica" -Script

This command outputs the Transact-SQL script that removes the availability replica named MainReplica from the availability group named MainAg. This command does not remove the replica.

Parameters

-Path

Specifies the path to the availability replica. This parameter is required.

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

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

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

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend

Type:ActionPreference
Aliases:infa
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Required:False
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
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

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

Specifies the AvailabilityReplica object for the replica to remove.

Type:AvailabilityReplica[]
Required:True
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Inputs

Microsoft.SqlServer.Management.Smo.AvailabilityReplica

Specifies the availability replica to remove.