Remove-AzResourceGroup
Removes a resource group.
Syntax
Remove-AzResourceGroup
[-Name] <String>
[-ForceDeletionType <String>]
[-Force]
[-AsJob]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-AzResourceGroup
-Id <String>
[-ForceDeletionType <String>]
[-Force]
[-AsJob]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-AzResourceGroup cmdlet removes an Azure resource group and its resources from the current subscription. To delete a resource, but leave the resource group, use the Remove-AzResource cmdlet.
Examples
Example 1: Remove a resource group
Remove-AzResourceGroup -Name "ContosoRG01"
This command removes the ContosoRG01 resource group from the subscription. The cmdlet prompts you for confirmation and returns no output.
Example 2: Remove a resource group without confirmation
Get-AzResourceGroup -Name "ContosoRG01" | Remove-AzResourceGroup -Force
This command uses the Get-AzResourceGroup cmdlet to get the resource group ContosoRG01, and then passes it to Remove-AzResourceGroup by using the pipeline operator. The Force parameter suppresses the confirmation prompt.
Example 3: Remove all resource groups
Get-AzResourceGroup | Remove-AzResourceGroup
This command uses the Get-AzResourceGroup cmdlet to get all resource groups, and then passes them to Remove-AzResourceGroup by using the pipeline operator.
Example 4: Remove a resource groups use ForceDeletionType
Remove-AzResourceGroup -Name "ContosoRG01" -ForceDeletionType "Microsoft.Compute/virtualMachineScaleSets,Microsoft.Compute/virtualMachines,Microsoft.Databricks/workspaces"
This command removes the ContosoRG01 resource group use the ForceDeletionType. The cmdlet prompts you for confirmation and returns no output.
Parameters
-ApiVersion
Specifies the API version that is supported by the resource Provider. You can specify a different version than the default version.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-AsJob
Run cmdlet in the background
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Forces the command to run without asking for user confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ForceDeletionType
The resource types you want to force delete.Currently, only the following is supported: forceDeletionTypes=Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Id
Specifies the ID of resource group to remove. Wildcard characters are not permitted.
Type: | String |
Aliases: | ResourceGroupId, ResourceId |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
Specifies the names of resource groups to remove. Wildcard characters are not permitted.
Type: | String |
Aliases: | ResourceGroupName |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Pre
Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Outputs
Related Links
Azure PowerShell