Get-AzResource

Retrieves information about Azure resources.

SYNOPSIS

Retrieves information about Azure resources.

SYNTAX

Get-AzResource [-Name <String>] [-ResourceType <String>] [-ExtensionName <String>] [-ProviderNamespace <String>] [-ApiVersion <String>] [-ResourceId <String>] [-ODataQuery <String>] [-TenantId <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]

DESCRIPTION

The Get-AzResource cmdlet retrieves information about Azure resources.

This cmdlet retrieves resources in the current subscription.

To search for resources in a specific resource group, use the ResourceGroupName parameter.

To search for a specific resource, use the Name parameter.

To search for resources of a specific type, use the ResourceType parameter.

To search for resources with a specific provider namespace, use the ProviderNamespace parameter.

PARAMETERS

Name Type Description
-Name System.String Specifies the name of the resource to retrieve.
-ResourceType System.String Specifies the type of the resource. For example, 'Microsoft.Compute/virtualMachines' or 'Microsoft.Storage/storageAccounts'.
-ExtensionName System.String Specifies the name of the resource provider extension.
-ProviderNamespace System.String Specifies the namespace of the resource provider. For example, 'Microsoft.Storage'.
-ApiVersion System.String Specifies the API version of the resource provider.
-ResourceId System.String Specifies the full resource ID of the resource.
-ODataQuery System.String Specifies an OData filter clause.
-TenantId System.String The Tenant ID to use.
-DefaultProfile Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer The credentials, account, tenant, and subscription for the command.

EXAMPLES

Example 1: Get all resources

PS

Get-AzResource

Example 2: Get all virtual machines

PS

Get-AzResource -ResourceType "Microsoft.Compute/virtualMachines"

Example 3: Get a specific resource by name and type

PS

Get-AzResource -Name "my-storage-account" -ResourceType "Microsoft.Storage/storageAccounts"

Example 4: Get resources using an OData query

PS

Get-AzResource -ODataQuery "location eq 'eastus' and type eq 'Microsoft.Network/virtualNetworks'"

INPUTS

None. You can pipe to this cmdlet.

OUTPUTS

Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResource
When used with the -AsHashTable parameter, Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResource[]

NOTES

This cmdlet is part of the Azure PowerShell module. For more information, see Get started with Azure PowerShell.

RELATED LINKS