Get-AzureResourceGroup

Get-AzureResourceGroup

Gets Azure resource groups

Syntax

Parameter Set: Default
Get-AzureResourceGroup [[-Name] <String> ] [ <CommonParameters>]

Detailed Description

The Get-AzureResourceGroup cmdlet gets the Azure resource groups in your subscription. You can use the Name parameter to select resource groups by name. The default is all resource groups.

An Azure resource is a user-managed Azure entity, such as a database server, database, or web site. An Azure resource group is a collection of Azure resources that are deployed as a unit.

Parameters

-Name<String>

Specifies the name of the resource group. Wildcards are not permitted. This parameter is optional. The default is all resource groups in the subscription

Aliases

ResourceGroupName

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    You can pipe input to this cmdlet by property name, but not by value.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.Azure.Commands.ResourceManagement.PSResourceGroup

    Returns an array of resource group objects.

Notes

  • The Get-AzureResourceGroup cmdlet is included in the Azure Resource Manager module beginning in module version 0.8.0.

Examples

Example 1: Get all resource groups

This command gets all resource groups in the subscription.

PS C:\> Get-AzureResourceGroup
Name:      Contoso
Location: West US
Resources:
Name Type Location
=============== ======================= ========
ConstosoWebSite Microsoft.Web/sites West US
sqlsvr03 Microsoft.Sql/servers West US
sqldb01 Microsoft.Sql/databases West US

Name: EngineerBlog
Location: East US
Resources:
Name Type Location
=============== ======================= ========
EngineerBlog Microsoft.Web/sites West US
EngSvr01 Microsoft.Sql/servers West US
EngDB02 Microsoft.Sql/databases West US

Example 2: Get resource groups by name

This command gets Azure resource groups in your subscription that have names that begin with "eng".

PS C:\> Get-AzureResourceGroup -Name EngineerBlog
Name:      EngineerBlog
Location: East US
Resources:
Name Type Location
=============== ======================= ========
EngineerBlog Microsoft.Web/sites West US
EngSvr01 Microsoft.Sql/servers West US
EngDB02 Microsoft.Sql/databases West US

Example 3: Get resource groups by other properties

The command uses the Where-Object, ForEach-Object, and Select-Object cmdlets to get the names of resource groups that include Azure database server farms. You can use commands like this one to find resource groups with resources or properties of interest.

The command uses the Get-AzureResourceGroup cmdlet to get all resource groups in the subscription. It pipes the resource groups to the Where-Object cmdlet, which returns only the resource groups that include server farm resources. The command pipes those resource groups to the Select-Object cmdlet, which returns only the value of the ResourceGroupName property of each resource group.

PS C:\> Get-AzureResourceGroup | Where-Object {$_.Resources.Type -like "*serverFarms*"} | Select-Object -Property ResourceGroupName
Contoso
EngineerBlog

New-AzureResourceGroup

Remove-AzureResourceGroup