Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Remove-AzureResourceGroup

Remove-AzureResourceGroup

microsoft.azure.commands.resources.dll

Synopsis

Deletes a resource group.

Syntax

Remove-AzureResourceGroup [-Name] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

Detailed Description

The Remove-AzureResourceGroup cmdlet deletes a resource group and its resources from your subscription. By default, Remove-AzureResourceGroup prompts you for confirmation. To suppress the prompt, use the Force parameter.To delete a resource, but leave the resource group, use the Remove-AzureResource cmdlet.

Parameters

-Name <String>

Specifies the names of resource groups to delete. This parameter is required. Wildcards are not permitted.Use -Name or its alias, -ResourceGroupName.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Force <SwitchParameter>

Suppresses the confirmation prompt. By default, Remove-AzureResource prompts you to confirm before deleting a resource group.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-PassThru <SwitchParameter>

Returns $True if the remove operation was successful and $False if it failed. By default, this cmdlet does not return any output.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

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

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

None

Return Type

None or System.Boolean

Notes

The Remove-AzureResourceGroup cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.

Examples

-------------------------- Example 1: Remove a resource group --------------------------

This command removes the ContosoRG01 resource group from the subscription. The cmdlet prompts for confirmation and does not return any output by default.

PS C:\>Remove-AzureResourceGroup -Name -ContosoRG01
Confirm

Are you sure you want to remove resource group 'ContosoRG01'

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

-------------------------- Example 2: Use the Force parameter --------------------------

This command deletes the ContosoRG01 resource group from the subscription. It uses the Get-AzureResourceGroup cmdlet to get the resource group and pipes the resource group (by name) to the Remove-AzureResourceGroup cmdlet. The Remove-AzureResourceGroup command uses the Verbose common parameter to get status information about the operation and the Force parameter to suppress the confirmation prompt.

PS C:\>Get-AzureResourceGroup -Name ContosoRG01 | Remove-AzureResourceGroup -Verbose -Force
VERBOSE: Performing the operation "Removing resource group ..." on target "ContosoRG01".

-------------------------- Example 3: Remove all resource groups --------------------------

This command deletes all resource groups in the subscription. To get all resource groups, it uses a Get-AzureResourceGroup command with no parameters. Then, it pipes the resource groups to the Remove-AzureResourceGroup cmdlet. The Remove-AzureResourceGroup command uses the Passthru parameter. As a result, the cmdlet returns a value of $True for each operation that succeeds.

PS C:\>Get-AzureResourceGroup | Remove-AzureResourceGroup -PassThru

Confirm

Are you sure you want to remove resource group 'ContosoRG01'

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

True



Confirm

Are you sure you want to remove resource group 'ContosoRG02'

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

True

Online Version