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

 

All content available through this Web Site is provided on an “AS IS” and “AS AVAILABLE” basis, with all faults. Tracston LTD makes no warranty or representation with respect to the quality, accuracy, or availability of the Web Site or any of its content.