Reputation: 13
Please help to format output of the command: Get-AzureRmVMUsage -Location "West US"
Right now it shows:
Name Current Value Limit Unit
Availability Sets 77 322000 Count
Total Regional Cores 4159 323000 Count
Virtual Machines 999 32220000 Count
How can I pipe/filter it out so it only shows the Value for Total Regional Cores?
Selecting name shows following:
Get-AzureRmVMUsage -Location "East US" -Verbose | Select Name
Name
----
Microsoft.Azure.Management.Compute.Models.UsageName
Microsoft.Azure.Management.Compute.Models.UsageName
Thanks, Dmitry
Upvotes: 1
Views: 1091
Reputation: 19195
You could use the following command.
(Get-AzureRmVMUsage -Location "East US"|select -ExpandProperty Name).LocalizedValue
Here it the result.
The root reason is Name
contain two child values:Value
and LocalizedValue
. If you select them directly, you will get Microsoft.Azure.Management.Compute.Models.UsageName
.
Update:
So how do I get the exact value that corresponds to Total Regonal Cores
Just use following command.
$names= Get-AzureRmVMUsage -Location "East US"
foreach($name in $names) {$results = [pscustomobject]@{'name'=$name.name.LocalizedValue;'value'=$name.CurrentValue};$results}
Update2:
There is a Total Regional Cores variable that holds the value of 5 in your example. I want the formatting to show just this value without showing anything else
foreach($name in $names) {$results = [pscustomobject]@{'name'=$name.name.LocalizedValue;'value'=$name.CurrentValue};$results | ?{$_.name -eq 'Total Regional Cores'}}
Upvotes: 1