Update-AzTag

In this Azure PowerShell article, we will discuss the syntax and usage of the Update-AzTag PowerShell command with examples of how to use this command.

Update-AzTag

This command helps you update the tags on an Azure resource or subscription. 

Syntax of Update-AzTag

Below is the syntax of the Update-AzTag PowerShell command.

Update-AzTag
      [-ResourceId] <String>
      [-Tag] <Hashtable>
      [-Operation] <TagPatchOperation>

Update-AzTag Examples

Example-1:

You can execute the below Azure PowerShell command to update the tags for the resource group using the below PowerShell cmdlet.

$mynewtags = @{"Apple"="ITS"; "Status01"="Startupnew"}
$resourceDetails = Get-AzResourceGroup -Name newresgroup
Update-AzTag -ResourceId $resourceDetails.ResourceId -Tag $mynewtags -Operation Merge

After executing the above command, I got the expected output as below

Id         : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/newresgroup/providers/Microsoft.Resources/tags/default
Name       : default
Type       : Microsoft.Resources/tags
Properties : 
             Name        Value     
             ==========  ==========
             Status01    Startupnew
             Apple       ITS       

You can check out the same output in the screenshot below

Update-AzTag

Example-2:

Similarly, you can update a new set of Azure tags for the subscription using the below PowerShell cmdlet.

$mynewtags = @{"Dept"="HR"}
$mysubscription = (Get-AzSubscription -SubscriptionName "Visual Studio Enterprise").Id
Update-AzTag -ResourceId "/subscriptions/$mysubscription" -Tag $mynewtags -Operation Merge

After executing the PowerShell script, I got the expected output below.

Id         : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/providers/Microsoft.Resources/tags/default
Name       : default
Type       : Microsoft.Resources/tags
Properties : 
             Name  Value
             ====  =====
             Dept  HR   

You can check out the same output in the screenshot below.

Update-AzTag PowerShell

You may also like following the articles below

Conclusion

This article discussed the syntax and usage of the Update-AzTag PowerShell command with examples of how to use this command. Thanks for reading this article !!!