共用方式為


Get-AzureResourceGroup

Get-AzureResourceGroup

Gets Azure resource groups.

Syntax

Parameter Set: GetMultiple
Get-AzureResourceGroup [[-Tag] <Hashtable> ] [-Detailed] [-Profile <AzureProfile> ] [ <CommonParameters>]

Parameter Set: GetSingle
Get-AzureResourceGroup [-Name] <String> [-Profile <AzureProfile> ] [ <CommonParameters>]

Detailed Description

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

Parameters

-Detailed

Indicates that this cmdlet displays detailed information about the objects that it retrieves.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of the resource group that this cmdlet retrieves. You can use the wildcard character (*).

Aliases

ResourceGroupName

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Profile<AzureProfile>

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Tag<Hashtable>

Specifies a hash table that contains a tag. For more information about tags, see the Tag parameter of the Set-AzureResourceGroup cmdlet. This cmdlet gets resource groups that have the tag that this cmdlet specifies.

Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 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 the 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

    This cmdlet returns resource groups.

Examples

Example 1: Get all resource groups and their details

This command gets all resource groups in the subscription. The command specifies the Detailed parameter to display details for all of the resource groups.

Get-AzureResourceGroup -Detailed

Example 2: Get resource groups by name

This command gets the resource groups in your subscription that have names that begin with the string eng.

Get-AzureResourceGroup -Name "eng*"

Example 3: Get resource group properties

This command gets all resource groups in your subscription. The command passes the resource groups to the Where-Object cmdlet, which returns only the resource groups that include server farm resources. The command passes those resource groups to the Select-Object cmdlet, which returns only the value of the ResourceGroupName property of each resource group.

Get-AzureResourceGroup -Detailed | Where-Object {$_.Resources.Type -like "*serverFarms*"} | Select-Object -Property "ResourceGroupName"

Example 4: Get resource groups by tag

This example gets resource groups by specifying a tag.

The first command gets resource groups that have a CostCenter tag with a value of Development.

Get-AzureResourceGroup -Tag @{Name="CostCenter";Value="Development"}

The second command gets all resource groups that have a CostCenter tag, regardless of its value.

Get-AzureResourceGroup -Tag @{Name="CostCenter"}

Example 5: Get all tags of a resource group

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

(Get-AzureResourceGroup -Name "ContosoRG").Tags

New-AzureResourceGroup

Remove-AzureResourceGroup

Remove-AzureResourceGroup

Select-Object

Where-Object