Reservations / Limits and Shares

Apparently when performing a Virtual Center upgrade from ‘2.5 Update 1’ to ‘Update 2’ caused some issues when someone on twitter upgraded, It gave some of the attached Virtual machines reservations and limits that did not exist before, this obviously caused a few problems, especially to the machines that had more memory allocated than was limited.
I was asked if there was a way to extract all the Limit/Reservation information from Virtual Center, the following script does just that, into a nice csv file which can be loaded into excel and sorted as needed…..
$Filename = "C:\MyInformation.csv"
Connect-VIServer MYSERVER
$myCol = @()
Foreach ($VM in (Get-View -ViewType VirtualMachine |Sort Name)){
	$MYInfo = "" |select-Object VMName,CPUReservation,CPULimit,CPUShares,MEMSize,MEMReservation,MEMLimit,MEMShares
	$MYInfo.VMName = $VM.Name
	$MYInfo.CPUReservation = $VM.Config.CpuAllocation.Reservation
	If ($VM.Config.CpuAllocation.Limit-eq "-1"){
		$MYInfo.CPULimit = "Unlimited"}
	Else{
		$MYInfo.CPULimit = $VM.Config.CpuAllocation.Limit
	}
	$MYInfo.CPUShares = $VM.Config.CpuAllocation.Shares.Shares
	$MYInfo.MEMSize = $VM.Config.Hardware.MemoryMB
	$MYInfo.MEMReservation = $VM.Config.MemoryAllocation.Reservation
	If ($VM.Config.MemoryAllocation.Limit-eq "-1"){
		$MYInfo.MEMLimit = "Unlimited"}
	Else{
		$MYInfo.MEMLimit = $VM.Config.MemoryAllocation.Limit
	}
	$MYInfo.MEMShares = $VM.Config.MemoryAllocation.Shares.Shares
	$myCol += $MYInfo
}
$myCol |Export-csv -NoTypeInformation $Filename
Alan Renouf
Alan Renouf

Product Manager at VMware by day, home lab tinkerer by night. I write about VMware and VCF, home automation, AI, and the robots gradually taking over my house in the Santa Cruz Mountains.

Articles: 590

2 Comments

  1. Thanks Gabrie, updated the post, not sure where my head was when I was posting that !

  2. Hi Alan,

    It was not caused by the ESX u3 update but the Virtual Center upgrade from 2.5u1 to u2.

    Thanks for the script it was very helpful.

    Gabrie

Comments are closed.