Hi Luc,
I'm trying to run your script but i'm getting the following error. I've made sure i've got the altest version of get-sata2.ps1
C:\scripts> $esx = Get-View -Id (Get-VMHost xxxxxxxxxx).Id
C:\scripts> $mystats = ./Get-Stat2.ps1 -entity $esx -start (Get-Date).AddDays(-3) -finish (Get-Date).AddDays(-2) -stat cpu.usage.average -interval HI4
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run
C:\scripts\Get-Stat2.ps1?
Do not run Run once Suspend Help (default is "D"): r
Exception calling "QueryPerf" with "1" argument(s): "A specified parameter was not correct.
querySpec.maxSample"
At C:\scripts\Get-Stat2.ps1:197 char:28
+ $stats = $perfMgr.QueryPerf <<<< ($PQSpec)
+ CategoryInfo : NotSpecified: (:smileyhappy: [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Cannot index into a null array.
At C:\scripts\Get-Stat2.ps1:201 char:11
+ if($stats[ <<<< 0].Value -eq $null) {return $null}
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Cannot index into a null array.
At C:\scripts\Get-Stat2.ps1:205 char:27
+ for($i = 0; $i -lt $stats[ <<<< 0].SampleInfo.Count; $i ++ ){
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
C:\scripts>