Vidhan Bhaskar
Vidhan Bhaskar

Reputation: 1

How to fetch cost management in azure subscription using powershell?

I need to fetch few data related to cost for my azure subscription which are as follows below:

  1. Fetch last 6 months cost by service. 2 Fetch last 6 months cost by resource group and resources

  2. Daily cost of last 15 days.

Pls suggest some useful powershell scripting idea.

I tried using powershell scripting to fetch those details but couldn't able to do so.

I also tried using rest API method, az search graph query and using powershell CMDLETS as well but i am not able to get any appropriate data.

I am expecting evryone to providing me any powershell scripting to fetch those data.

Upvotes: 0

Views: 1215

Answers (1)

NickFrei
NickFrei

Reputation: 1

Here is a sample command.

Invoke-AzCostManagementQuery -Scope "/subscriptions/***********" -Timeframe MonthToDate -Type Usage -DatasetGranularity 'Daily'

Column                Row
------                ---
{UsageDate, Currency} {20201101 USD, 20201102 USD, 20201103 USD, 20201104 USD…}

Documentation: https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/invoke-azcostmanagementquery?view=azps-9.1.0

Module: https://learn.microsoft.com/en-us/powershell/module/az.costmanagement/?view=azps-9.1.0

Upvotes: 0

Related Questions