Pages: [1]
Print
Author Topic: List ESX Host, Host Memory Amount, VM Count, Memory Allocated to VM's  (Read 1266 times)
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« on: December 18, 2009, 08:44:02 AM »

Code:
Get-VMhost | select Name, MemoryTotalMB,
@{Name="nVMs"; Expression={ ($_ | Get-VM | Measure-Object).Count } },
@{ Name="VM_Mem"; Expression= { ($_ | get-vm | measure-object -property memorymb -sum).sum } }
Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: December 23, 2009, 10:08:23 AM »

here is some cleaner code

Code:
foreach ($vmhost in get-cluster | get-vmhost)
{
$meminfo = $vmhost | get-vm | measure-object -property memorymb -sum
$guestcount = $vmhost | get-vm |  measure-object
    "" | select-object @{Name="Host"; Expression={$vmhost.name}},
                       @{Name="Num VM's"; Expression={$guestcount.count}},
                       @{Name="Mem Allocation"; Expression={$meminfo.Sum}}
 } 
 
Logged
Pages: [1]
Print
Jump to: