更改订阅下所有资源组的标签名称

Change the tag name for all resourcegroups under subscription

我需要更改标签键,但值应该保持不变。例如,我有一个名为“SkuId =1234”的标签。我需要将键值更改为“SystemId =1234”。尝试了类似下面的操作。没有用...有什么建议吗?

$resourceGroups = Get-AzResourceGroup
foreach($resourcegroup in $resourceGroups){
$Tags = (Get-AzResourceGroup -Name $resourceGroup).Tags
$Tags += @{"SystemId"=$tags.oldtag}
$Tags.Remove('oldtag')
$resourceGroup.resourcegroupname |Set-AzureRmResourceGroup -Tag $Tags
}

尝试这样的事情:

$Tags = (Get-AzResourceGroup).Tags
$Tags += @{"SystemId"=$tags.oldtag}
$Tags.Remove('oldtag')
Set-AzureRmResourceGroup -Tag $Tags