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.