Try something like this.
Note that the script will produce incorrect results should one of the VMs be poweredoff/poweredon during the interval.
To cover that situation, the script will need to be changed.
$clusterName = 'N-MMK-COOP-151-16'
$startDate = Get-Date 27/9/2016
$finishDate = Get-Date 18/10/2016
$vms = Get-Cluster -Name $clusterName | Get-VM
$report = Get-Stat -Entity $vms -Start $startDate -Finish $finishDate -CPU -ErrorAction SilentlyContinue |
Group-Object -Property Timestamp | Sort-Object -Property Name | %{
$obj = [ordered]@{
Date = $_.Name
}
$_.Group | Group-Object -Property {$_.Entity.Name} | Sort-Object -Property Name | %{
$_.Group | Sort-Object -Property MetricId | %{
$obj.Add("$($_.Entity.Name)/$($_.MetricId)",$_.Value)
}
}
New-Object PSObject -Property $obj
}
$report | Export-Csv C:\report.csv -NoTypeInformation -UseCulture