Remove-AzureRmResourceGroup

Remove-AzureRmResourceGroup

Deletes a resource group.

Syntax

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

Detailed Description

This is the Description section

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

Parameters

-Force

Suppresses the confirmation prompt. By default, Remove-AzureRmResource 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

-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

ResourceGroupName

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-PassThru

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

-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.

Inputs

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

  • None

Outputs

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

  • None or System.Boolean

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-AzureRmResourceGroup -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-AzureRmResourceGroup cmdlet to get the resource group and pipes the resource group (by name) to the Remove-AzureRmResourceGroup cmdlet. The Remove-AzureRmResourceGroup 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-AzureRmResourceGroup -Name ContosoRG01 | Remove-AzureRmResourceGroup -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-AzureRmResourceGroup command with no parameters. Then, it pipes the resource groups to the Remove-AzureRmResourceGroup cmdlet. The Remove-AzureRmResourceGroup command uses the Passthru parameter. As a result, the cmdlet returns a value of $True for each operation that succeeds.

PS C:\>Get-AzureRmResourceGroup | Remove-AzureRmResourceGroup -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