I have a function that I have been using to collect Min,Max,Avg for CPU and Memory. The function collects data from the last month and returns a single value for each item. After reading about the New-VIProperty I thought I would try to adapt the function into Cluster properties. I got the property working except it returns an array of values instead of a single value. I would like help tweaking the 1st property and then I can create the others. I am going to attach the working function and the non working property.
Working Function
FunctionMin_Max_Avg ($E, $C, $S) {
Get-Stat-Entity$E-Stat$C-Start$S |
Group-Object-Property {$_.Entity.Name} | %{
$stats=$_.Group | Measure-Object-PropertyValue-Average-Maximum-Minimum
}
$Avg= [math]::round(($stats.Average), 0)
$Min= [math]::round(($stats.Minimum), 0)
$Max= [math]::round(($stats.Maximum), 0)
Return$Avg,$Min,$Max }
Non working Property
#MemoryMinUsageMonth -MB
New-VIProperty-NameMemoryMinUsageMonth-ObjectTypeCluster -Value{
param($cluster)
$start= (Get-Date).AddMonths(-1)
Get-Stat-Entity$cluster-Statmem.usage.average-Start$start
Group-Object-Property {$cluster.Entity.Name} | %{
$stats=$cluster.Group | Measure-Object-PropertyValue-Minimum
}
$Min= [math]::round(($stats.Minimum), 0)
$Min
}