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