I want to generate VM consumption for the last 3 months separately in 3 different columns , for eg : Nov-Dec in 1st column , Dec-Jan in 2nd column and Jan-feb in 3rd column and exporting this data into CSV. I am using :
$startDate=Get-Date
for($i=1 ; $i -le 3; $i++)
{
$currentdate=$startDate.AddMonths(-$i)
$enddate=$startDate.AddMonths(-$i+1)
$infos = Get-AzConsumptionUsageDetail -StartDate $currentdate -EndDate $endDate - ResourceGroup $ResourceGroup
$infos | Where-Object {$_.Product -like "*$sku*" -and $_.InstanceLocation -like
"$Region"} | Export-Csv -NoTypeInformation -Path .\"$($subscription).csv"
}
Here I am passing the value for $sku as Virtual machine through a function . This script is giving me the usagequantity details in 1 column itself for all the 3 months but I want it in 3 different columns