![Update Azure Resource Tags Update Azure Resource Tags (PowerShell)](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFM-KelGeT1azx1KvPCEy6z8Qal6bs9oIdhjWhpUVp5wBenRfb-gQm-4jtODjHdW-nI8LqpcBJp3UFew88jFPoOJCyhdRRsfFC99PuV10a9tQRl2W3kXxB-UyJ2PeE0yJIDBWEU0t__mk3GNZbMN2pmU90YaqVhwZirytPdreFdRv2UY4TBs8ovDUO/s1600-rw/update-azure-resource-tags.webp)
Add or Update Tags to Azure Subscription:
PowerShell Script: Add or update subscription tags with Merge Operations in Azure.
$NewTags = @{ "BusinessArea"=""; "ITTeam"=""; "Solution"=""; "ChargebackTo"=""; "Environment"=""; } Update-AzTag -ResourceId "/subscriptions/{_add_subid_}" \ -Tag $NewTags \ -Operation Merge
Add Tags to Multiple Resources in Azure:
PowerShell Script: With this script you can add tags to multiple resources by selecting a target resource group in Azure.
# Fill the variable details $Subscription="_add_subscription_name_here_" $RGName="_add_resource_group_name_here_" # Add/Update Tag Name and Values $tagApplicationName="_add_tag_value_"; $tagOperationsArea="_add_tag_value_"; $tagOwnerName="_add_tag_value_"; $tagOwnerEmail="_add_tag_value_"; Set-AzContext -SubscriptionName "$Subscription" $RGs=Get-AzResourceGroup -Name "$RGName" $Resources=Get-AzResource -ResourceGroupName $RGs.ResourceGroupName foreach ($Resource in $Resources){ $ResourceId = $Resource.ResourceId $ResourceName = $Resource.Name $mergedTags = @{ ApplicationName="$tagApplicationName"; OperationsArea="$tagOperationsArea"; OwnerName="$tagOwnerName"; OwnerEmail="$tagOwnerEmail"; } Update-AzTag -ResourceId $ResourceId -Tag $mergedTags -Operation Merge Write-Output "Tags has been added successfully for the RG:$ResourceName `n" }
Note: save the script file with .ps1 extension.