Powershell to delete all resources from Azure resource group with specific tag
Problem -> If we want to cleanup all resource for cost saving and if the all resources have some tag set then we can remove all resources automatically using powershell
Solution 1 – delete all resources with specific tag across subscription
$tagname = “resourcetype”
$TagValue =”Service Fabric”
Find-AzureRmResource -TagName $tagname -TagValue $TagValue | Remove-AzureRmResource -force
Solution 2 – delete all resources with specific tag from specific resource group
$rg= “TestRG”
$tagname = “resourcetype”
$TagValue =”Service Fabric”
Find-AzureRmResource -TagName $tagname -TagValue $TagValue |where{$_.resourcegroupname -eq $rg}| Remove-AzureRmResource -force
note – change below values before use
$rg= “TestRG”
$tagname = “resourcetype”
$TagValue =”Service Fabric”
Comments are closed.