Get-VMStat


posted by Richard Giles
02-27-2009

Downloads: 413
File size: 809 B
Views: 1,856

Embed
Get-VMStat
  1. # Andy Hill 
  2. # http://virtualandy.wordpress.com/2009/02/05/get-vmstat-and-resource-allocation/ 
  3. # Required: VI Toolkit 
  4. # Retrieve average CPU and RAM for specified VMs for elapsed period in hours 
  5.  
  6. function Get-VMStat 
  7.     param( $VM,[Int32]$Hours = 1 ) 
  8.      $VM | Sort Name | 
  9.          Select Name, @{N="CPU";E={[Math]::Round((($_
  10.          Get-Stat -Stat cpu.usage.average -Start (Get-Date).AddHours(-$Hours) -IntervalMins 5 -MaxSamples ($Hours*12) | 
  11.          Measure-Object Value -Average).Average),2)}}, @{N="MEM";E={[Math]::Round((($_
  12.          Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-$Hours) -IntervalMins 5 -MaxSamples ($Hours*12) | 
  13.          Measure-Object Value -Average).Average),2)}} 
  14.  
  15. #Example Usage 
  16. # you will be asked for your VC server   
  17. # PS> Get-VC  
  18. # PS> Get-VMStat (Get-VM) -Hours 2160 

Retrieve average CPU and RAM for specified VMs for elapsed period in hours

Attributed To: Hugo Peeters

URL: Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 http://www.peetersonline.nl/index.php/vmware/vmware-stats-oneliner/

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.