Get-AzConsumptionUsageDetail - How to sum all PretaxCost rows returned and save to an excel or csv file?

ScottM 331 Reputation points
2020-11-06T15:59:49.227+00:00

Is there an example for how to sum the PretaxCost property for all objects returned by Get-AzConsumptionUsageDetail?

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,035 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,113 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,364 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 44,776 Reputation points
    2020-11-06T16:14:00.977+00:00

    The cmdlet returns a PSUsageObject, so this might be what you need:

    Get-AzConsumptionUsageDetail |
        Measure-Object -Sum -Property PretaxCost
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful