Remove-SqlAvailabilityGroup

SYNOPSIS

Removes an availability group.

SYNTAX

ByPath (Default)

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

ByObject

Remove-SqlAvailabilityGroup [-InputObject] <AvailabilityGroup[]> [-Script]
 [-InformationAction <ActionPreference>] [-InformationVariable <String>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

The Remove-SqlAvailabilityGroup cmdlet removes an availability group in AlwaysOn Availability Groups. You can run this cmdlet on any instance of SQL Server that has AlwaysOn Availability Groups enabled on a Windows Server Failover Clustering (WSFC) node that has security credentials for the availability group.

EXAMPLES

Example 1: Remove an availabity group

PS C:\> Remove-SqlAvailabilityGroup -Path "SQLSERVER:\Sql\Server\InstanceName\AvailabilityGroups\MainAG"

This command removes the availability group named MainAG. You can run this command on any server instance that hosts an availability replica for the availability group.

Example 2: Remove all availability groups

PS C:\> Get-ChildItem "SQLSERVER:\Sql\Server\InstanceName\AvailabilityGroups" | Remove-SqlAvailabilityGroup

This command gets all availability groups that have availability replicas in the specified location in the SQLSERVER: provider. The command passes them to the current cmdlet by using the pipeline operator. That cmdlet deletes each availability group.

Example 3: Create a script to remove an availability group

PS C:\> Remove-SqlAvailabilityGroup -Path "SQLSERVER:\Sql\Server\InstanceName\AvailabilityGroups\MainAG" -Script

This command creates a Transact-SQL script that removes the availability group named MainAG. The command does not perform this action.

PARAMETERS

-Path

Specifies the path of the availability group that this cmdlet removes.

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 cmdlet returns a Transact-SQL script that performs the task that this cmdlet performs.

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 availability group that this cmdlet removes.

Type: AvailabilityGroup[]
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.AvailabilityGroup

OUTPUTS

NOTES

Join-SqlAvailabilityGroup

New-SqlAvailabilityGroup

Set-SqlAvailabilityGroup

Switch-SqlAvailabilityGroup

Test-SqlAvailabilityGroup