You mean something like this ?
It collects the IOPS for the complete previous day and send the result via email
$metrics="disk.numberwrite.summation","disk.numberread.summation"
$finish=Get-Date-Hour0-Minute0-Second0
$start=$finish.AddDays(-1)
$report=@()
$vms=Get-VM|where {$_.PowerState-eq"PoweredOn"}
$stats=Get-Stat-Stat$metrics-Entity$vms-Start$start-Finish$finish
$interval=$stats[0].IntervalSecs
$lunTab=@{}
foreach($dsin (Get-Datastore-VM$vms|where {$_.Type-eq"VMFS"})){
$ds.ExtensionData.Info.Vmfs.Extent|%{
$lunTab[$_.DiskName] =$ds.Name
}
}
$report=$stats|Group-Object-Property {$_.Entity.Name},Instance|%{
$readStat=$_.Group|
where{$_.MetricId-eq"disk.numberread.summation"} |
Measure-Object-PropertyValue-Average-Maximum
$writeStat=$_.Group|
where{$_.MetricId-eq"disk.numberwrite.summation"} |
Measure-Object-PropertyValue-Average-Maximum
New-ObjectPSObject-Property@{
VM=$_.Values[0]
Start=$start
Finish=$finish
Disk=$_.Values[1]
IOPSWriteMax= [math]::Round($writeStat.Maximum/$interval,0)
IOPSWriteAvg= [math]::Round($writeStat.Average/$interval,0)
IOPSReadMax= [math]::Round($readStat.Maximum/$interval,0)
IOPSReadAvg= [math]::Round($readStat.Average/$interval,0)
Datastore=$lunTab[$_.Values[1]]
}
}
Send-MailMessage-Subject"IOPS Report"-Fromlucd@lucd.info`
-Tolucd@lucd.info-SmtpServermail.lucd.info`
-BodyAsHtml-Body ($report|SelectVM,Start,Finish,Disk,Datastore,IOPSWriteAvg,
IOPSWriteMax,IOPSReadAvg,IOPSReadMax|ConvertTo-Html|Out-String)