Remove-AzureResourceGroup
Remove-AzureResourceGroup
Deletes a resource group.
Syntax
Parameter Set: Default
Remove-AzureResourceGroup [-Name] <String> [-Force] [-PassThru] [-Confirm] [-WhatIf] [ <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
-Force
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 |
-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: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. 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.
None
You can pipe input to the cmdlet by property name, but not by value.
Outputs
The output type is the type of the objects that the cmdlet emits.
None or System.Boolean
When you use the PassThru parameter, Remove-AzureResourceGroup returns $True if the operation succeeded and $False if it failed. Otherwise, this cmdlet does not generate any output.
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