Oneliner for the road
Okay, so I’ve just announced I won’t post anything for the coming month. You must all feel very sad.
Well, before leaving you sobbing over an empty feed reader, here’s one more oneliner. One for the road.
Get-VMHost | Sort Name | Get-View | Select Name, @{N=”MemoryGB”;E={[math]::Round((($_.Summary.Hardware.MemorySize)/1GB),0)}}, @{N=”MemoryUsageGB”;E={[math]::Round((($_.summary.quickstats.overallmemoryusage)*1MB/1GB),2)}}, @{N=”Percentage”;E={[Math]::Round(100*(($_.Summary.QuickStats.OverallMemoryUsage*1MB/1GB)/($_.Summary.Hardware.MemorySize/1GB)),0)}}
What the *bleep* does that do? I’ll explain it to you:
- It grabs your VMware Servers (Get-VMHost)
- Sorts them by Name (Sort Name)
- Gets the advanced properties (Get-View)
- Selects some properties to show you (Select), being:
- The server Name (Name)
- Something called MemoryMB, which is the value of the Summary.Hardware.MemorySize property devided by 1 GB and rounded to zero digits.
- Something called MemoryUsageGB, which is the value of the Summary.QuickStats.OverallMemoryUsage property (which is already in MBs), converted to GBs and rounded to two digits.
- Something called Percentage, which is 100 times the MemoryUsage in GBs divided by the Memory in GBs, rounded to zero digits.
Can’t you do something like that with Get-Stat?
Sure, but wouldn’t be near as much fun.
Adios!
Hugo
2 Responses to Oneliner for the road
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





I transcribed this one-liner and another into workflows and ran them using PowerWF Studio. I mentioned and linked to your site in the youtube video: http://www.youtube.com/watch?v=tArvdM-ZI70
Cool! Thanks for mentioning the site. I appreciate it.
Hugo