Remove-AzureResourceGroup

Remove-AzureResourceGroup

Deletes a resource group.

Syntax

Parameter Set: Default
Remove-AzureResourceGroup [-Name] <String> [-Force] [-PassThru] [-Profile <AzureProfile> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Remove-AzureResourceGroup cmdlet deletes a resource group and its resources from your subscription. By default, this cmdlet prompts you for confirmation. To delete a resource without removing a resource group, use the Remove-AzureResource cmdlet. For more information about Azure resources and Azure resource groups, see the New-AzureResourceGroup cmdlet.

Parameters

-Force

Forces the command to run without asking for user confirmation.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of the resource group that this cmdlet removes.

Aliases

ResourceGroupName

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-PassThru

Indicates that this cmdlet returns $True if the remove operation succeeds, or $False if it fails. By default, this cmdlet returns no output.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Profile<AzureProfile>

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.Azure.Commands.ResourceManagement.PSResourceGroup

    This cmdlet accepts a resource group.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Boolean

    This cmdlet returns a Boolean value, if you specify the PassThru parameter.

Examples

Example 1: Remove a resource group

This command removes the resource group named ContosoRG01 from your subscription. The cmdlet prompts you for confirmation.

Remove-AzureResourceGroup -Name "ContosoRG01"

Example 2: Remove a resource group without confirmation

This command gets the resource group named ContosoRG01 by using the Get-AzureResourceGroup cmdlet. It passes that group to the current cmdlet by using the pipeline operator. The command specifies the Force parameter. Therefore, the command does not prompt you for confirmation. This command uses the Verbose common parameter to display output.

Get-AzureResourceGroup -Name "ContosoRG01" | Remove-AzureResourceGroup -Verbose -Force

Example 3: Remove all resource groups

This command removes all resource groups in the subscription. The command gets all resource groups, and passes each of them to the current cmdlet. The current cmdlet removes each group. The command prompts you for each group that it deletes. This command specifies the PassThru parameter. The command returns a value of $True for each group that it deletes.

Get-AzureResourceGroup | Remove-AzureResourceGroup -PassThru

Get-AzureResourceGroup

New-AzureResourceGroup

Remove-AzureResource