Remove-SqlAvailabilityReplica

SYNOPSIS

Removes a secondary availability replica.

SYNTAX

ByPath (Default)

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

ByObject

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[]
Parameter Sets: ByPath
Aliases: 

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
Parameter Sets: (All)
Aliases: 

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
Parameter Sets: (All)
Aliases: infa

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InformationVariable

Specifies an information variable.

Type: String
Parameter Sets: (All)
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
Parameter Sets: (All)
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
Parameter Sets: (All)
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[]
Parameter Sets: ByObject
Aliases: 

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

Microsoft.SqlServer.Management.Smo.AvailabilityReplica

Specifies the availability replica to remove.

OUTPUTS

NOTES

New-SqlAvailabilityReplica

Set-SqlAvailabilityReplica

Test-SqlAvailabilityReplica