Script to find all virtual machines with swapping memory

This script will list all virtual machines with swapping memory:

$findswap = @()
foreach($vm in (Get-View -ViewType VirtualMachine | Where-Object `
{$_.Summary.QuickStats.SwappedMemory -ne “0”})){
$select = “” | Select-Object VM, `
SwappedMemory

$select.VM = $vm.Name
$select.SwappedMemory = $vm.Summary.QuickStats.SwappedMemory

$findswap += $select
}
$findswap

Leave a Comment

Your email address will not be published. Required fields are marked *