none
Apply Resource Group tags to all the resources in side the resource group

    Question

  • Hello All,

    I am trying to apply resource group tags to all the resources in side the resource group. I am able to achieve this with the below code. Which applies on all the resource group.

    I want to select a specific resource group name and want perform this operation on single resource group. How can I do that?

    $groups = Get-AzureRmResourceGroup
    foreach ($g in $groups)
    {
        Find-AzureRmResource -ResourceGroupNameEquals $g.ResourceGroupName | ForEach-Object {Set-AzureRmResource -ResourceId $_.ResourceId -Tag $g.Tags -Force }
    }


    suresh guntha

    Friday, February 3, 2017 6:37 AM

All replies

  • Hi Suresh,

    you can define the resource group name in the Get-AzureRmResourceGroup cmdlet:

    $g = Get-AzureRmResourceGroup -Name "YourRGName"
    Find-AzureRmResource -ResourceGroupNameEquals $g.ResourceGroupName | ForEach-Object {Set-AzureRmResource -ResourceId $_.ResourceId -Tag $g.Tags -Force }


    Floris van der Ploeg - www.florisvanderploeg.com

    If my post was helpfull, remember to click the "Propose as answer" button.

    • Proposed as answer by Cloud_Crusader Friday, February 3, 2017 9:51 AM
    Friday, February 3, 2017 9:05 AM