How to overwrite Tags on an Azure Resource

With the limitation of 15 Tags per resource, you will reach a point that you need to intervene and either remove some of the tags or reuse them. On my previous post (How to update specified tag from a resource) I showed a way to update a specific tag in a Azure Resource. Some time that will be enough, other time you need to overwrite what is implemented by a new value, and not to add a value to the Tags hash table.

In case you need to overwrite the existing Tags with a new value(s), please use the following PowerShell cmdlet. In this scenario, I want to overwrite 2 Tags (Shutdown and Test).


foreach ($VM in $VMs) { 
  $tags = @{“Shutdown” = “Yes”; “Test” = “No”}

  Set-AzureRmResource -ResourceId $VM.Id -ApiVersion 2015-06-15 -Tag $tags


Marcos Nogueira
Azure MVP
Twitter: @mdnoga

Marcos Nogueira

With more than 18 years experience in Datacenter Architectures, Marcos Nogueira is currently working as a Principal Cloud Solution Architect. He is an expert in Private and Hybrid Cloud, with a focus on Microsoft Azure, Virtualization and System Center. He has worked in several industries, including Aerospace, Transportation, Energy, Manufacturing, Financial Services, Government, Health Care, Telecoms, IT Services, and Gas & Oil in different countries and continents. Marcos was a Canadian MVP in System Center Cloud & Datacenter Managenment and he has +14 years as Microsoft Certified, with more than 100+ certifications (MCT, MCSE, and MCITP, among others). Marcos is also certified in VMware, CompTIA and ITIL v3. He assisted Microsoft in the development of workshops and special events on Private & Hybrid Cloud, Azure, System Center, Windows Server, Hyper-V and as a speaker at several Microsoft TechEd/Ignite and communities events around the world.

Leave a Reply

Your email address will not be published. Required fields are marked *