Thursday, February 4, 2010

Using PowerShell to find guests with memory swapped out

I often need to determine if any VMs have memory swapped out (swcur in ESXTOP). I've been using PowerShell and the PowerCLI to generate a list due to its extreme simplicity.

Get-VM | where-object {$_.powerstate -eq "PoweredOn"} | get-stat -Realtime -Stat "mem.swapped.average" -MaxSamples 1 | Select Entity, Value | where-object { $_.Value -gt 0 } |sort-object -property Entity

You can pipe the results to a CSV by appending " | export-csv" to the end of the statement.

No comments:

Post a Comment