Azure.Resources Module Get-AzResource

Get-AzResource

The Get-AzResource cmdlet retrieves resources in Azure Resource Manager. You can use this cmdlet to get a specific resource or all resources within a resource group, subscription, or management group.

Syntax

Get-AzResource [-ApiVersion ] [-Body ] [-ClientAssembly ] [-ClientObjectId ] [-ODataFilter ] [-ODataQuery ] [-ProviderName ] [-ResourceGroupName ] [-ResourceName ] [-ResourceType ] [-SubscriptionId ] [-DefaultProfile ] []

        

Parameters

Name Type Description
-ApiVersion [String] Specifies the API version of the resource type to use.
-Body [Object] Specifies the body of the resource to get.
-ClientAssembly [Assembly] Specifies the assembly for the client.
-ClientObjectId [Guid] Specifies the object ID of the client.
-ODataFilter [String] Specifies an OData filter to apply to the query.
-ODataQuery [String] Specifies an OData query to apply to the request.
-ProviderName [String] Specifies the resource provider name, such as Microsoft.Storage.
-ResourceGroupName [String] Specifies the name of the resource group that contains the resources.
-ResourceName [String] Specifies the name of the resource.
-ResourceType [String] Specifies the type of the resource, such as Microsoft.Storage/storageAccounts.
-SubscriptionId [Guid] Specifies the ID of the subscription.
-DefaultProfile [IAzureContextContainer] The credentials, account, tenant, and subscription that are used for communication with Azure.

Examples

Example 1: Get all resources in the current subscription

Get-AzResource

Example 2: Get all resources in a specific resource group

Get-AzResource -ResourceGroupName "MyResourceGroup"

Example 3: Get a specific resource by name and type

Get-AzResource -ResourceGroupName "MyResourceGroup" -ResourceType "Microsoft.Storage/storageAccounts" -ResourceName "mystorageaccount"

Example 4: Get all storage accounts in a resource group

Get-AzResource -ResourceGroupName "MyResourceGroup" -ResourceType "Microsoft.Storage/storageAccounts"

Example 5: Filter resources by tag

Get-AzResource -Tag @{"Environment"="Production"}