This is my first time writing a script to pull metrics from the virtual environment and I am trying to pull out the total disk latency and disk iops for each VM in the environment.
Here are the relevant portions that I have so far:
#Get powered on VMs
$VMs = Get-VM | ?{$_.powerstate -eq "PoweredOn"}
#Loop through each VM
foreach ($vm in $VMs) {
$dskreadlatency = Get-Stat -Entity $vm -Stat "disk.totalreadlatency.average" -Start $start -Finish $end
$dskwritelatency = Get-Stat -Entity $vm -Stat "disk.totalwritelatency.average" -Start $start -Finish $end
$dsknumberwrites = Get-Stat -Entity $vm -Stat "virtualdisk.numberwriteaveraged.average" -Start $start -Finish $end
$dsknumberreads= Get-Stat -Entity $vm -Stat "virtualdisk.numberreadaveraged.average" -Start $start -Finish $end
}
#setting fields to the averages of the stats (I have 4 of these)
$fieldX = [string]([Math]::Round((($dskYYY | Measure-Object Value -Average).Average),2))
I'm unfortunately getting 0 for all of these stats. My level settings are all set at 2. It would be great if I could receive assistance regarding this.