Remove-AzTag
Deletes predefined Azure tags or values | Deletes the entire set of tags on a resource or subscription.
Syntax
RemovePredefinedTagParameterSet
Remove-AzTag
[-Name] <String>
[[-Value] <String[]>]
[-PassThru]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
RemoveByResourceIdParameterSet
Remove-AzTag
-ResourceId <String>
[-PassThru]
[-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 object when passing in "-PassThru".
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
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 |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Parameter properties
Type: | IAzureContextContainer |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | 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.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
RemovePredefinedTagParameterSet
Position: | 0 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-PassThru
Returns an object that represents the deleted tag or the resulting tag with deleted valued.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-ResourceId
The resource identifier for the tagged entity. A resource, a resource group or a subscription may be tagged.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
RemoveByResourceIdParameterSet
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Value
Deletes the specified values from the predefined tag, but does not delete the tag.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
RemovePredefinedTagParameterSet
Position: | 1 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
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.