PowerCLI

 View Only
  • 1.  Modifying PowerCLI script for Get-Stat2 ?

    Posted Sep 22, 2017 06:39 AM

    Hi All,

    I wonder if anyone here can assist me in using the script created by LucD  http://www.lucd.info/download/Get-Stat2.ps1 to get the VM statistics:

    Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Select Name, Host, NumCpu, MemoryMB, `

    @{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, `

    @{N="Memory Usage (Average), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `

    @{N="Network Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , `

    @{N="Disk Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} |

    Export-Csv -Path C:\TEMP\AverageUsage.csv -NoTypeInformation

    The above script does not show anything even after I raised the Statistics to level 3 in the morning. Like this one:

    Thanks in advance,



  • 2.  RE: Modifying PowerCLI script for Get-Stat2 ?

    Posted Sep 22, 2017 04:44 PM

    Worked for me in a 6.0 vcenter that I have setup running statistics level 3,2,2,2.  Thinking that since you just changed the levels that there isn't enough data yet in the database to give you the 30 day average sample.  Maybe try using 1 day if that is how long it has been since you increased the statistics level. 



  • 3.  RE: Modifying PowerCLI script for Get-Stat2 ?

    Posted Sep 23, 2017 11:46 PM

    cbelnap, yes, Luc has confirmed that to me in the other thread, so now I wonder if the script above can be modified using Get-Stat2 ?