How to delete all the tags of the azure resource using PowerShell?


To delete all the tags of the Azure VM using PowerShell, we need to use the Remove-AZTag command.

To delete the azure resource tags, we need its resource ID but before that, it is always better to take azure resource tags backup. You can search the question on the TutorialPoints site or google,

Site − TutorialsPoint.com How to Export the Azure VM tags using PowerShell?

To delete the azure Resource Tags,

PS C:\> $vm = Get-AzVM -Name Testmachine2k16
PS C:\> Remove-AzTag -ResourceId $vm.Id -Verbose

To remove the azure resourceGroup tags,

PS C:\> $rg = Get-AzResourceGroup AnsibleTestRG
PS C:\> Remove-AzTag -ResourceId $rg.ResourceId -Verbose

To remove the individual tag, you can directly apply the tag name but be cautious as it will remove the given tag name across all the subscriptions.

The below command will remove the tag from the entire subscription if it is not associated with multiple resources.

Remove-AzTag -Name 'Owner' -Value 'Chirag' -Verbose

If you have done something wrong while removing tags and if you have already a TAGS backup, you can search on the google article to import the tags again.

Site − TutorialsPoint.com How to import tags in Azure?

Updated on: 06-Apr-2021

565 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements