Archive for October, 2009
Getting Virtual Machine CPU, Disk and Memory
Thursday, October 22nd, 2009I was asked to pull disk, memory and cpu statistics from VMware guests managed by multiple Virtual Center servers. Working with the VMWare Senior Administrator, we came up with this.
$CsvFile = "C:\VM_Hosts_Info.csv" $CsvData = @() $VCSrvs = "VCenter01","VCenter02","VCenter03" ForEach ($VCSrv in $VCSrvs){ Connect-VIServer -server $VCSrv Get-VM | % { $VM = $_ $Disk_T = "{0:N1}" -f(($VM | Get-HardDisk | measure-object -property CapacityKB -sum).Sum/1mb) $Row = "" | Select Name,Environment,MemoryMB,NumCPU,Total_DiskGB $Row.Name = $VM.Name $Row.Environment = $VCSrv $Row.MemoryMb = $VM.MemoryMb $Row.NumCpu = $VM.NumCpu $Row.Total_DiskGB = $Disk_T $CsvData += $Row }} $CsvData | Export-Csv $CsvFile -noTypeInformation
Hope this helps.
All information is provided on an AS-IS basis, with no warranties and confers no rights.
