May 25th, 2016

PowerTip: Get all Azure Resource Manager resource groups with PowerShell

Doctor Scripto
Scripter

Summary: Using the AzureRM cmdlets to get a list of resource groups.

Hey, Scripting Guy! Question I have a client who has a large list of resource groups. Can you show me how to get a filtered list?

Hey, Scripting Guy! Answer Just use the Get-AzureRMResourceGroup cmdlet and pipe the results to Where-Object. To identify all resource groups that start with HSG in the name, try this;

Get-AzureRMResourceGroup | Where-Object { $_.ResourceGroupName –like ‘HSG*’ }

The Doctor

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Akhil Vasu

    Get-AzureRmResourceGroup | where ResourceGroupName -notlike “*brick*”

    This is working for me.

    I need to filter one more key word. How to modify the above command.

    I tried many ways Get-AzureRmResourceGroup | where {ResourceGroupName -notlike “*brick*” -or ResourceGroupName -notlike “*sm*”}
    nothing helped. Please help me.