Get-AzureResource
Get-AzureResource
Gets Azure resources.
Syntax
Parameter Set: List resources
Get-AzureResource [-Profile <Microsoft.Azure.Common.Authentication.Models.AzureProfile> ] [-ResourceGroupName <String> ] [-ResourceType <String> ] [-Tag <Hashtable> ] [ <CommonParameters>]
Parameter Set: Get a single resource
Get-AzureResource [-Name] <String> -ApiVersion <String> -ResourceGroupName <String> -ResourceType <String> [-ParentResource <String> ] [-Profile <Microsoft.Azure.Common.Authentication.Models.AzureProfile> ] [ <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
-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 |
-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 |
ResourceName |
Required? |
true |
Position? |
1 |
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 |
-Profile<Microsoft.Azure.Common.Authentication.Models.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 |
-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? |
true |
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? |
true |
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
.
The Tag parameter is introduced in version 0.8.5 of the AzureResourceManager module.
Aliases |
none |
Required? |
false |
Position? |
named |
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 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.Models.PSResource
Returns objects that represent the resources.
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 command gets all Azure resources in the subscription.
Get-AzureResource
Example 2: Get resources by resource group
This commands gets all Azure resources in the ContosoRG01 resource group.
Get-AzureResource -ResourceGroupName ContosoRG01
Example 3: Get resources by resource type
These commands get all resources with a specified resource type.
The first command finds the types of resources in the subscription. It uses the Get-AzureResource cmdlet to get all resources and Group-Object cmdlet to group the objects by resource type. The output shows that there are server farms and web sites in the subscription.
The second command uses the ResourceType parameter of Get-AzureResource to get all server farms in the subscription.
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
Example 4: Get a resource by name
This command 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.
You can also use the Where-Object cmdlet to select a resource. For example: Get-AzureResource | Where-Object Name -eq "ConsotoLabWeb"
Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-04-01
Example 5: Get a resource by its tag
This command gets resources that have a tag named "Department with a value of "IT".
The Tag parameter is introduced in version 0.8.5 of the AzureResourceManager module.
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.
The Tag parameter is introduced in version 0.8.5 of the AzureResourceManager module.
Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-04-01
PS C:\>(Get-AzureResource -Name ContosoLabWeb -ResourceGroupName ContosoLabsRG -ResourceType "Microsoft.Web/sites" -ApiVersion 2015-04-01).Tags
Tags:
Name Value
==== ======
Department IT
Status Approved
FY2016