Find Amortized Cost for Azure resources via PowerShell

olegarr 131 Reputation points
2025-06-13T12:57:44.5533333+00:00

Hello:

I am trying to collect cost for Azure resources via Powershell. I have a script, but recently realized I am collecting actual, but not amortized cost. That means if any of my resources covered by Reserve Instance and/or Savings Plan I do not see real cost.

This is what I am using now, but again, it's collecting only actual cost, but I need amortized:

$ResourceConsumption = Get-AzConsumptionUsageDetail -StartDate $startDate -EndDate $endDate -InstanceId $resource.ID

Is it possible (and how) to collect Amortized cost for Azure resources via PowerShell?

Thank you!

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,970 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,181 Reputation points
    2025-06-16T14:44:03.34+00:00

    I try to answer PS questions, but I don't use Azure and don't have a clue about amortized costs.

    I did this search.

    https://www.bing.com/search?q=azure%20amortized%20costs%20powershell%20example

    CoPilot returned this script. I see that there is a IncludeAmortizedCost switch. Did you see that? Does this help?

    # Connect to Azure account
    Connect-AzAccount
    # Set the subscription context (replace with your Subscription ID)
    $SubscriptionId = "your-subscription-id"
    Set-AzContext -SubscriptionId $SubscriptionId
    # Define the time range for the cost query
    $StartDate = (Get-Date).AddDays(-30).ToString("yyyy-MM-dd")  # Last 30 days
    $EndDate = (Get-Date).ToString("yyyy-MM-dd")
    # Query the cost details with amortized cost enabled
    $CostDetails = Get-AzConsumptionUsageDetail -StartDate $StartDate -EndDate $EndDate -IncludeAmortizedCost
    # Display the results
    $CostDetails | Select-Object ResourceName, ResourceGroupName, AmortizedCost, UsageStart, UsageEnd | Format-Table
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.