Hi @DeHaven Graham ,
Thank you for posting this question on Microsoft Q&A.
I understand that you are trying to update Tag Names in bulk (by only changing the case of contained letters) for resources in your resource group/subscription.
Please note that Tag Names are case insensitive, but tag values are case sensitive. That is why you cannot update the TagName without deleting the tag Name/value pair if you are only updating the case of Tag name (changing 'test' to 'Test' ).
You can use Update-AzTag
to achieve this, but it will require both operations of this cmdlet - "Delete" and "Merge". Please see this link for more details. As a sample, I am providing the script below which updates the casing of a particular TagName for all resources in a resource group.
Note: The script below is for demo purpose only and provided as-is, without any warranty. Please test the script before using it in production.
#assuming that the tagName and value are @{'test'='someValue'}
#and this needs to be changed to @{'Test'='someValue'} #---note that only the tag name has been updated. The value is preserved
$old_TagName = 'test' #Tag name with lowercase 't'
$new_TagName = 'Test' #The new tag n
#Scope for the operation. In this case, all resources of a resource group.
$RESOURCE_GROUP = 'test-resourceGroup'
#Get all the resources from a resource group
$resources = Get-AzResource -ResourceGroupName 'test-resourceGroup'
$tempVal = ""
foreach($resource in $resources)
{
if($resource.Tags.ContainsKey($old_TagName))
{
$tempVal = $resource.Tags[$old_TagName]
$deletedTags = @{$old_TagName = $tempVal}
#update-Tag with DELETE operation
$null = Update-AzTag -ResourceId $resource.ResourceId -Tag $deletedTags -Operation Delete
Write-Output "Updating for : $($resource.Name)"
Write-Output "Old Tag Name and Value : {$old_TagName : $tempVal}"
Write-Output "Updated Tag Name and Value : {$new_TagName : $tempval}"
Write-Output "---------------------------------------------------------"
$mergedTags = @{$new_TagName = $tempVal}
#Update-Tag with MERGE Operation
$null = Update-AzTag -ResourceId $resource.ResourceId -Tag $mergedTags -Operation Merge
$tempVal = "" #reset the tag value
}
}
Please let me know if you have any questions.
---
Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.