Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Get-AzureResource

Get-AzureResource

microsoft.azure.commands.resources.dll

Synopsis

Gets Azure resources

Syntax

Get-AzureResource [-ResourceGroupName] [-ResourceType] [-Tag] [<CommonParameters>]

Get-AzureResource [-Name] [-ResourceGroupName] [-ResourceType] [-ParentResource] [-ApiVersion] [<CommonParameters>]

Detailed Description

The Get-AzureResource cmdlet gets the Azure resources in the subscription. By default, it gets all resources in the subscription, but you can use the parameters in the cmdlet to filter the results.An Azure resource is a user-managed Azure entity, such as a database server, database, or website. Every Azure resource is associated with a resource group, which is a collection of resources that are deployed as a unit.

Parameters

-ResourceGroupName <String>

Gets only resources in the specified resource group. Wildcards are not permitted. This parameter is required only when you are selecting resources by name. By default, Get-AzureResource gets all resources in the subscription.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ResourceType <String>

Gets only resources of the specified resource type. Wildcards are not permitted. This parameter is required only when you are selecting resources by name. By default, GetAzureResource gets all resources in the subscription.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Tag <Hashtable>

Gets resources that have the specified Azure tag. Enter a hash table with a Name key or Name and Value keys. Wildcard characters are not supported.A "tag" is a name-value pair that you can apply to resources and resource groups. Use tags to categorize your resources, such as by department or cost center, or to track notes or comments about the resources. To add a tag to a resource, use the Tag parameter of the New-AzureResource or Set-AzureResource cmdlets. To create a predefined tag, use the New-AzureTag cmdlet.For help with hash tables in Windows PowerShell, type: Get-Help about_Hashtables.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Name <String>

Gets a resource with the specified name. Wildcards are not permitted. This parameter is required only when you are selecting resource by name. By default, Get-AzureResource gets all resources in the subscription.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ParentResource <String>

Gets only resources that are children of the specified parent resource. Enter the fully qualified name of the parent resource, such as " Microsoft.Sql/servers/ContosoSQLSvr". Wildcards are not permitted.Use this parameter when the resource is a type that has parents. For example, every SQL Azure database is associated with a SQL Azure database server. A resource group is not a parent of its resources.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ApiVersion <String>

Specifies the API version that is supported by the resource provider. This parameter is required when you use the Name parameter.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

Input Type

None

Return Type

Microsoft.Azure.Commands.ResourceManagement.Models.PSResource

Notes

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

Examples

-------------------------- Example 1: Get all resources --------------------------

This commands gets all Azure resources in the subscription.

PS C:\>Get-AzureResource
Name              : HostingFarm1
ResourceGroupName : ContosoHosting
ResourceType      : Microsoft.Web/serverFarms
Location          : southcentralus
ParentResource        : 


Name              : ContosoDev
ResourceGroupName : ContosoLabsRG
ResourceType      : Microsoft.Web/sites
Location          : southcentralus
ParentResource        : 
                       
...

-------------------------- Example 2: Get resources by resource group --------------------------

This commands gets all Azure resources in the ContosoRG01 resource group.

PS C:\>Get-AzureResource -ResourceGroupName ContosoRG01
                       
Name              : Default1
ResourceGroupName : ContosoLabsRG
ResourceType      : Microsoft.Web/serverFarms
Location          : northeurope
ParentResource        : 


Name              : ContosoLabWeb
ResourceGroupName : ContosoLabsRG
ResourceType      : Microsoft.Web/sites
Location          : northeurope
ParentResource        :

-------------------------- Example 3: Get resources by resource type --------------------------

These commands get all resources with a specified resource type.

PS C:\>Get-AzureResource | Group-Object ResourceType

Count Name                      Group
----- ----                      -----
    6 microsoft.insights/ale... {@{Name=ServerErrors-goorg016
    6 microsoft.insights/aut... {@{Name=Default23-foorg016; R
    6 microsoft.insights/com... {@{Name=goorg016ws; ResourceG
    1 Microsoft.Web/serverFarms {@{Name=Default1; ResourceGro
    6 Microsoft.Web/sites       {@{Name=utr2520; ResourceGrou

PS C:\>Get-AzureResource -ResourceType Microsoft.Web/serverFarms
Name              : Default1
ResourceGroupName : ContosoLabsRG
ResourceType      : Microsoft.Web/serverFarms
Location          : southcentralus
ParentResource        : 


Name              : Default1
ResourceGroupName : ContosoRG01
ResourceType      : Microsoft.Web/serverFarms
Location          : northeurope
ParentResource        : 


Name              : Default1
ResourceGroupName : ContosoEngineering
ResourceType      : Microsoft.Web/serverFarms
Location          : southcentralus
ParentResource        : 


Name              : Default2
ResourceGroupName : ContosoEngineering
ResourceType      : Microsoft.Web/serverFarms
Location          : southcentralus
ParentResource        :

-------------------------- Example 4: Get a resource by name --------------------------

This commands gets the "ContosoLabWeb" web site resource. When you use the Name parameter to get a particular resource, the ResourceGroupName, ResourceType, and APIVersion parameters are required.

PS C:\>Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2014-04-01
Name              : ContosoLabWeb
ResourceGroupName : ContosoLabsRG
ResourceType      : Microsoft.Web/sites
ParentResource    : 
Location          : North Europe
Properties        : 
                    {[name, ContosoLabWeb], [state, Running], [hostNames, 
                     System.Collections.Generic.List`1[System.Object]], [webSpace,
                     ContosoLabsRG-NorthEuropewebspace]...} 
Tags              :

-------------------------- Example 5: Get a resource by its tag --------------------------

This command gets resources that have a tag named "Department with a value of "IT".

PS C:\>Get-AzureResource -Tag @{Name="Department";Value="IT"}

-------------------------- Example 6: Get all tags of a resource --------------------------

These commands get all tags of the ContosoWeb resource. The first command gets the resource by name with all of its properties. The second command, which uses the Tags property of the output object, gets only the tags.

PS C:\>Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2014-04-01

PS C:\>(Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2014-04-01).Tags


Tags: 

      Name        Value
      ====        ======
      Department  IT
      Status      Approved
      FY2016

Online Version