Remove-AzureRmResourceGroup

Removes a resource group.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Remove-AzureRmResourceGroup
      [-Name] <String>
      [-Force]
      [-AsJob]
      [-ApiVersion <String>]
      [-Pre]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzureRmResourceGroup
      [-Id] <String>
      [-Force]
      [-AsJob]
      [-ApiVersion <String>]
      [-Pre]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Remove-AzureRmResourceGroup 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-AzureRmResource cmdlet.

Examples

Example 1: Remove a resource group

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

PS C:\>Get-AzureRmResourceGroup -Name "ContosoRG01" | Remove-AzureRmResourceGroup -Verbose -Force

This command uses the Get-AzureRmResourceGroup cmdlet to get the resource group ContosoRG01, and then passes it to Remove-AzureRmResourceGroup by using the pipeline operator. The Verbose common parameter gets status information about the operation, and the Force parameter suppresses the confirmation prompt.

Example 3: Remove all resource groups

PS C:\>Get-AzureRmResourceGroup | Remove-AzureRmResourceGroup

This command uses the Get-AzureRmResourceGroup cmdlet to get all resource groups, and then passes them to Remove-AzureRmResourceGroup by using the pipeline operator.

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

-Id

Specifies the ID of resource group to remove. Wildcard characters are not permitted.

Type:String
Aliases:ResourceGroupId, ResourceId
Position:0
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