Thanks alot LucD, that was exactly what I needed. I put a foreach to get the information for each folder and now I would like to export it to a CSV. Can you help me with this?
$folders = Get-Folder -Location VIRTUAL_MACHINES -Type VM -NoRecursion
foreach($folder in $folders){
$cpu,$memory,$storage = Get-Folder -Name $folder | Get-VM |
select @{N='CPU';E={$_.ExtensionData.Summary.Quickstats.OverallCpuUsage}},
@{N='Memory';E={$_.ExtensionData.Summary.Quickstats.GuestMemoryUsage}},
UsedSpaceGB |
Measure-Object -Property CPU,Memory,UsedSpaceGB -Sum |
Select -ExpandProperty Sum
'' | Select @{N='Folder';E={$folder}},@{N='CPU';E={$cpu}},@{N='Memory';E={$memory}},@{N='Storage';E={[math]::Round($storage,2)}}
}