I have some Azure usage data in the structure as returned from the Azure management cmdlet Get-UsageAggregates
. This has some information in a property of type Json, from which I want to extract a sub-property.
These data are contained in variable $usage
. If I execute
$usage.UsageAggregations.properties |
select-object metercategory,metersubcategory,unit,quantity
,@{Name="resource"; Expression={$_.InstanceData }}
I get a list of objects like this:
MeterCategory : Storage
MeterSubCategory : Geo Redundant
Unit : GB
Quantity : 3.76344
resource : {"Microsoft.Resources":{"resourceUri":"/subscriptions/[GUID]/resourceGroups/default-storage-
northeurope/providers/Microsoft.ClassicStorage/storageAccounts/MyAccountName","location":"eunorth"}}
I would like to see the "MyAccountName" instead of the JSON string. How can I do that?
I tried to use
$usage.UsageAggregations.properties |
select-object metercategory,metersubcategory,unit,quantity
,@{Name="resource";
Expression={$_.InstanceData |
ConvertFrom-Json |
select-object -Property Microsoft.Resources.resourceuri }}
But the output is
MeterCategory : Storage
MeterSubCategory : Geo Redundant
Unit : GB
Quantity : 3.76344
resource : @{Microsoft.Resources.resourceuri=}
Adding .value
after resourceuri
also did not help.