Get-AzResourceGroup

In this article, we will discuss how to get all Resource Groups in a subscription using PowerShell, and it’s never a big task. You need to use the Get-AzResourceGroup Azure PowerShell cmdlet. Let’s discuss a few words on how to use Get-AzResourceGroup and the use of Get-AzResourceGroup Azure PowerShell to list Resource Groups.

Get-AzResourceGroup

An excellent Azure PowerShell cmdlet to retrieve the Resource Groups.

Syntax of Get-AzResourceGroup:

Get-AzResourceGroup [[-Name] <String>] [[-Location] <String>] 

And,

Get-AzResourceGroup [[-Location] <String>] [-Id <String>]

After executing the Get-AzResourceGroup Azure PowerShell cmdlet, there is a chance you might get an error. You can check out the below article to fix the same issue.

Related article: The ‘Get-AzResourceGroup’ command was found in the module ‘Az.Resources’

Let’s check out some examples.

Get-AzResourceGroup Examples:

Example-1: Below cmdlet will get you a list of all the resource Groups available.

Get-AzResourceGroup

After executing the above Azure PowerShell cmdlet, I got the below output.


PS C:\WINDOWS\system32> Get-AzResourceGroup


ResourceGroupName : NetworkWatcherRG
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /NetworkWatcherRG

ResourceGroupName : Default-Storage-SouthCentralUS
Location          : southcentralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /Default-Storage-SouthCentralUS

ResourceGroupName : MyNewresgroupupdt
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
                    Name    Value  
                    ======  =======
                    Status  Startup
                    TSINFO  IT     
                    
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /MyNewresgroupupdt

ResourceGroupName : mynewfunctionapp235
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /mynewfunctionapp235

ResourceGroupName : myjavascriptazurefunctio
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /myjavascriptazurefunction

ResourceGroupName : mynewazurefunctionapp25
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /mynewazurefunctionapp25

ResourceGroupName : MyNewResGrp
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /MyNewResGrp

ResourceGroupName : DefaultResourceGroup-CUS
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /DefaultResourceGroup-CUS

ResourceGroupName : newresgroup-260369671
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /newresgroup-260369671

ResourceGroupName : newresgroup-1443124578
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /newresgroup-1443124578

ResourceGroupName : mynewupdatedazurefnapp
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /mynewupdatedazurefnapp

ResourceGroupName : Demo123
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /Demo123

ResourceGroupName : DemoVM1
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /DemoVM1

ResourceGroupName : DemoVM2
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /DemoVM2

ResourceGroupName : mypythondemoapp1
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /mypythondemoapp1

ResourceGroupName : mynewresgrp1
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /mynewresgrp1

ResourceGroupName : demoRsgGroup
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /demoRsgGroup

You can see it here

azure powershell list resource groups

Example 2: Below cmdlet will get you the details of the Resource Group named Demo123.

Get-AzResourceGroup -Name "demo358"

After executing the above Azure PowerShell cmdlet, I got the below output.

ResourceGroupName : demo358
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demo358

You can also check out the same output in the screenshot below

azure powershell get all resource groups in a subscription

Example-3: Below cmdlet will get all the resource groups from the centralus region.

Get-AzResourceGroup -Location centralus

The output will be like this with all the resource groups from the centralus region.

ResourceGroupName : demo358
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demo358

ResourceGroupName : Demo12346
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo12346

You can see the same output in the screenshot below

get azure resource group PowerShell

Example-4: Below, the cmdlet will get you the lists of resource groups whose name starts with Demo.

Get-AzResourceGroup -Name Demo*

After executing the above Azure PowerShell cmdlet, I got the below output.

ResourceGroupName : demo357
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demo357

ResourceGroupName : demo358
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demo358

ResourceGroupName : Demo12346
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo12346

ResourceGroupName : demoRsgGroup
Location          : eastus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demoRsgGroup

You can see the same output in the screenshot below