Azure PowerShell List Resource Groups

Well, In this article, we will discuss how to get lists of Resource Groups using PowerShell. Along with this, we will discuss a few other topics as mentioned below.

Azure PowerShell List Resource Groups

You might get the requirements to retrieve the lists of resource groups using PowerShell and it’s never a big task, you just need to use the Get-AzResourceGroup Azure PowerShell cmdlet. Let’s discuss a few words on how to use Get-AzResourceGroup and what is the use of Get-AzResourceGroup Azure PowerShell cmdlet.

Get-AzResourceGroup

An excellent Azure PowerShell cmdlet to retrieve the Resource Groups.

Syntax:

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.

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.

Read: How to find Resource id in Azure portal


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

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

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

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 "Demo123"

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

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

Example-3: Below cmdlet will get you 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 : deletelistresourcegroup
Location          : centralus
ProvisioningState : Succeeded
Tags              : 
ResourceId        : /subscriptions/1cdf4300-dee5-3498-9c9c-feaa72a5cbd1/resourceGroups
                    /deletelistresourcegroup

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

Get-AzResourceGroup -Name Demo*

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

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

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

You may also like following the below articles

Wrapping Up

Well, in this article, we learnt how to get Resource Groups using PowerShell and the syntax and usage of Get-AzResourceGroup Azure PowerShell cmdlet with examples.