Forum Navigation
You need to log in to create posts and topics.

Azure Resources

Problem

User wants to get information about Azure resources

Solutions

Get all the resourceIds along with tags for a subscription

Get-AzResource|select ResourceId,Tags

 

Get all the resourceIds in a subscription based on tag value

Get-AzResource -TagValue “<tag value>” |select ResourceId

 

 

The new AZ Module is recommended for operating towards Azure from Powershell (cross platform and newer Powershell versions). For more information look here: https://docs.microsoft.com/en-us/powershell/module/az.resources/get-azresource

Example getting resources by tag using hashtable:

$resources = Get-AzResource -tag @{“costCenter”=”100011”;}
# No filter – get all resource s
$resources = Get-AzResource;
$resources = Get-AzureRMResource -tag @{“costCenter”=”100011”;}

or by using -tagName -tagValue

$resources = Get-AzResource -TagName “costCenter” -TagValue “100111”;
$resources = Get-AzureRMResource -TagName “costCenter” -TagValue “100111”;

You then have all the resources in your $resources variable – so you can easily select the ResourceId and/or tags (and other properties):

$resources|Select ResourceId

If you want to discover what properties are on an object in resources – experiment with this:

$resources[0]|Get-Member