Remove-AzTag

Deletes predefined Azure tags or values | Deletes the entire set of tags on a resource or subscription.

Syntax

Remove-AzTag
      [-Name] <String>
      [[-Value] <String[]>]
      [-PassThru]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzTag
      [-PassThru]
      -ResourceId <String>
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

RemovePredefinedTagSet: The Remove-AzTag cmdlet deletes predefined Azure tags and values from your subscription. To delete particular values from a predefined tag, use the Value parameter. By default, Remove-AzTag deletes the specified tag and all of its values.You cannot delete a tag or value that is currently applied to a resource or resource group. Before using Remove-AzTag, use the Tag parameter of the Set-AzResourceGroup cmdlet to delete the tag or values from the resource or resource group. The Azure Tags module that Remove-AzTag is part of can help you manage your predefined Azure tags. An Azure tag is a name-value pair that you can use to categorize your Azure resources and resource groups, such as by department or cost center, or to track notes or comments about the resources and groups. You can define and apply tags in a single step, but predefined tags let you establish standard, consistent, predictable names and values for the tags in your subscription.

RemoveByResourceIdParameterSet: The Remove-AzTag cmdlet with a ResourceId deletes the entire set of tags on a resource or subscription.

Examples

Example 1: Delete a predefined tag

Remove-AzTag -Name "Department"

This command deletes the predefined tag named Department and all of its values. If the tag has been applied to any resources or resource groups, the command fails.

Example 2: Delete a value from a predefined tag

Remove-AzTag -Name "Department" -Value "HumanResources" -PassThru

Name:   Department
Count:  14
Values: 

        Name        Count
        =========   =====

        Finance        2
        IT            12

This command deletes the HumanResources value from the predefined Department tag. It does not delete the tag. If the value has been applied to any resources or resource groups, the command fails.

Example 3: Deletes the entire set of tags on a subscription

Remove-AzTag -ResourceId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

This command deletes the entire set of tags on the subscription with {subId}. It will not return the object deleted if not passing in "-PassThru".

Example 4: Deletes the entire set of tags on a resource

Remove-AzTag -ResourceId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/testrg/providers/Microsoft.Sql/servers/Server1 -PassThru

Id         : {Id}
Name       : {Name}
Type       : {Type}
Properties :
             Name     Value
             =======  =========
             Dept     Finance
             Status   Normal

This command deletes the entire set of tags on the resource with {resourceId}. It returns the deleted oject when passing in "-PassThru".

Parameters

-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

-Name

Specifies the Name of the predefined tag to remove. By default, Remove-AzTag removes the specified tag and all of its values. To delete selected values, but not delete the tag, use the Value parameter.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

Returns an object that represents the deleted tag or the resulting tag with deleted valued.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ResourceId

The resource identifier for the tagged entity. A resource, a resource group or a subscription may be tagged.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Value

Deletes the specified values from the predefined tag, but does not delete the tag.

Type:String[]
Position:1
Default value:None
Required:False
Accept pipeline input:True
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

String

String[]

SwitchParameter

Outputs

Microsoft.Azure.Commands.ResourceManager.Common.Tags.PSTag | Microsoft.Azure.Commands.Tags.Model.PSTagResource