Here you go.
And I would take the maximum of the maximum values, instead of the average. It depends of course what exactly you want to do with this report, but the absolute maximum would be a significant factor when right-sizing VM memory.
$start= (Get-Date).AddDays(-7)$metrics="mem.active.average","mem.active.maximum","mem.consumed.average","mem.granted.average"
$vms=Get-VMGet-Stat-Entity$vms-Stat$metrics-Start$start|Group-Object-Property {$_.Entity.Name} |%{ $ordered=$_.Group|Sort-Object-PropertyTimestamp
New-ObjectPSObject-Property@{ VM=$_.Group[0].Entity.Name
StartTime=$ordered[0].Timestamp
ActiveAvg=$ordered|where {$_.MetricId-eq"mem.active.average"} |Measure-Object-PropertyValue-Average|select-ExpandPropertyAverage
ActiveMax=$ordered|where {$_.MetricId-eq"mem.active.maximum"} |Measure-Object-PropertyValue-Maximum|select-ExpandPropertyMaximum
ConsumedAvg=$ordered|where {$_.MetricId-eq"mem.consumed.average"} |Measure-Object-PropertyValue-Average|select-ExpandPropertyAverage
GrantedAvg=$ordered|where {$_.MetricId-eq"mem.granted.average"} |Measure-Object-PropertyValue-Average|select-ExpandPropertyAverage
} } |Export-Csvc:\report.csv-NoTypeInformation-UseCulture