Rashida11
Contributor
Contributor

VMware Summary Report

Hi all I am trying to write a script to generate a VMWare summary Report of each cluster wer have in our Virtual Center for our QA Department

I will like to get the

1) Total number of hosts in each cluster and the total amount of memory and cpu of the hosts in the cluster.

2)Total number of assigned memory of all the virtual images in the cluster as well as the total number of memory actually used

3)Total number of assigned CPU of all the virtual images in the cluster as well as the total number of CPU actually used

export all this data to word document .....

Any ideas??

Ras

0 Kudos
5 Replies
hugopeeters
Hot Shot
Hot Shot

Hi Rashida,

This script should get you started. Try expanding it with the rest of the information.

Regards,

Hugo

http://www.peetersonline.nl

0 Kudos
Rashida11
Contributor
Contributor

Thanks Hugo.

I have had a play with the scripts and is pull back my values as need.

ForEach ($cluster in $clusters)

{

$vmhosts = Get-VMHost -Location $cluster

$vms = Get-VM -Location $cluster

$TotalVMMemoryMB = $vms | Measure-Object -Property MemoryMB -Sum

ForEach ($VMhostView in ($vmhosts | Get-View))

{

$TotalHostMemory += $vmhostView.Hardware.MemorySize

}

$myClusterObj = "" | Select-Object Name, NumHosts, NumVMs, TotalRAM_GB, AssignedRAM_GB, PercentageUsed

$myClusterObj.Name = $cluster.Name

$myClusterObj.NumHosts = ($vmhosts | Measure-Object).Count

$myClusterObj.NumVMs = $vms.Length

$myClusterObj.TotalRAM_GB = ::Round($TotalHostMemory/1GB,$digits)

$myClusterObj.AssignedRAM_GB = ::Round($TotalVMMemoryMB.Sum/1024,$digits)

$myClusterObj.PercentageUsed = ::Round((($TotalVMMemoryMB.Sum/1024)/($TotalHostMemory/1GB))*100)

$myCol += $myClusterObj

Clear-Variable vmhosts -ErrorAction SilentlyContinue

Clear-Variable vms -ErrorAction SilentlyContinue

Clear-Variable TotalMemoryMB -ErrorAction SilentlyContinue

Clear-Variable TotalHostMemory -ErrorAction SilentlyContinue

}

However it returns values for all the Virtual machine powered off or on and templates. I looking to see If it can only return values for running images only

Cheers

Rashida

0 Kudos
hugopeeters
Hot Shot
Hot Shot

Change

$vm = Get-VM -Location $Cluster

Into

$vm = Get-VM -Location $Cluster | Where {$_.PowerState -eq "PoweredOn"}

virtualkid
Contributor
Contributor

That was a nice script. I am new to this forum and trying to find some cool scripts to get started on some monitoring projects, so thanks you

virtualkid

www.realmoneysavers.com

0 Kudos
Rashida11
Contributor
Contributor

Cheers

Thet worked fine-- Output tallyies with the right readings

Name NumHosts NumVMs TotalRAM_GB AssignedRAM_GB PercentageUsed

-


-


-


-


-


-


CLUSTER1 8 128 0 0

CLUSTER2 13 83 208 168 81

CLUSTER3 1 4 16 14 88

I just need to add 2 more sections for

Amount of memory Actually used

Percentage of Memory Actually used

0 Kudos