Remove-AzResourceGroup
Deletes a resource group and all resources it contains.
Syntax
RemoveByResourceGroupName (Default)
Remove-AzResourceGroup
[-Name] <string>
[-ForceDeletionType <string>]
[-Force]
[-SubscriptionId <string>]
[-Profile <string>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
RemoveByResourceGroupId
Remove-AzResourceGroup
-Id <string>
[-ForceDeletionType <string>]
[-Force]
[-SubscriptionId <string>]
[-Profile <string>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Aliases
This cmdlet has no aliases.
Description
Deletes a resource group, including its resources, deployments, and stored deployment operations.
Specify the resource group by name or by resource ID.
The cmdlet waits for deletion to finish and returns True when the operation succeeds.
Examples
Example 1: Delete a resource group by name
Delete a resource group in the active subscription without a confirmation prompt.
Remove-AzResourceGroup -Name myresourcegroup -Force
Example 2: Delete a resource group by resource ID
Delete a resource group by using its full ARM resource ID.
Remove-AzResourceGroup -Id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup -Force
Example 3: Preview a resource group deletion
Show what the cmdlet would delete without sending the delete request.
Remove-AzResourceGroup -Name myresourcegroup -WhatIf
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Force
Deletes the resource group without prompting for confirmation.
This parameter does not override -WhatIf.
Parameter properties
| Type: | SwitchParameter |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-ForceDeletionType
Specifies resource types that Azure should force delete.
Supported values include Microsoft.Compute/virtualMachines, Microsoft.Compute/virtualMachineScaleSets, and Microsoft.Databricks/workspaces.
Parameter properties
| Type: | String |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Id
Specifies the full ARM resource ID of the resource group.
Parameter properties
| Type: | String |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ResourceGroupId, ResourceId |
Parameter sets
RemoveByResourceGroupId
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-Name
Specifies the name of the resource group.
Parameter properties
| Type: | String |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ResourceGroupName |
Parameter sets
RemoveByResourceGroupName
| Position: | 0 |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-Profile
Specifies a saved profile to use instead of the active profile.
Parameter properties
| Type: | String |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-SubscriptionId
Specifies the Azure subscription ID. When omitted, the cmdlet uses the active profile's subscription.
Parameter properties
| Type: | String |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-WhatIf
Runs the command in a mode that only reports what would happen without performing the actions.
Parameter properties
| Type: | SwitchParameter |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
String
You can pipe a resource group name or resource group ID to this cmdlet by property name.
Outputs
Boolean
Returns True after the resource group deletion completes successfully.
Notes
Deleting a resource group permanently deletes all resources contained in the group.