Get-AzureRmResourceGroup

Gets resource groups.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

Get-AzureRmResourceGroup
   [-Name <String>]
   [-Location <String>]
   [-Tag <Hashtable>]
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzureRmResourceGroup
   [-Location <String>]
   [-Id <String>]
   [-ApiVersion <String>]
   [-Pre]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Get-AzureRmResourceGroup cmdlet gets Azure resource groups in the current subscription. You can get all resource groups, or specify a resource group by name or by other properties. By default, this cmdlet gets all resource groups in the current subscription. For more information about Azure resources and Azure resource groups, see the New-AzureRmResourceGroup cmdlet.

Examples

Example 1: Get a resource group by name

PS C:\>Get-AzureRmResourceGroup -Name "EngineerBlog"

This command gets the Azure resource group in your subscription named EngineerBlog.

Example 2: Get all tags of a resource group

PS C:\>(Get-AzureRmResourceGroup -Name "ContosoRG").Tags

This command gets the resource group named ContosoRG, and displays the tags associated with that group.

Example 3: Show the Resource groups by location

PS C:\> Get-AzureRmResourceGroup |
  Sort Location,ResourceGroupName |
  Format-Table -GroupBy Location ResourceGroupName,ProvisioningState,Tags

Example 4: Show the names of all the Resource groups in a particular location

PS C:\> Get-AzureRmResourceGroup -Location westus2 |
   Sort ResourceGroupName | 
   Format-Wide ResourceGroupName -Column 4

Example 5: Show the Resource groups whose names begin with WebServer

PS C:\> Get-AzureRmResourceGroup | Where ResourceGroupName -like WebServer*

Parameters

-ApiVersion

Specifies the API version that is supported by the resource Provider. You can specify a different version than the default version.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Id

Specifies the ID of the resource group to get. Wildcard characters are not permitted.

Type:String
Aliases:ResourceGroupId, ResourceId
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Location

Specifies the location of the resource group to get.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Name

Specifies the name of the resource group to get. This parameter supports wildcards at the beginning and/or the end of the string.

Type:String
Aliases:ResourceGroupName
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Pre

Indicates that this cmdlet considers pre-release API versions when it automatically determines which version to use.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Tag

The tag hashtable to filter resource groups by.

Type:Hashtable
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

Inputs

None

Outputs

Microsoft.Azure.Commands.ResourceManagement.PSResourceGroup