VMware Cloud Community
jessem
Enthusiast
Enthusiast

Removing "Reserve all guest memory (All Locked)"

Hello,

I am trying to remove a checkbox for memory setting - "Reserve all guest memory (All Locked)" on some VMs in a cluster.  I am trying to run a powercli command on a "per-cluster" basis.

Any help is appreciated.

0 Kudos
1 Reply
Zsoldier
Expert
Expert

Seems to be a new thing in 5.5.  Never noticed it before, but was a fun exercise for me.  This is written to change ALL VM's.  There is no checking to see whether the box is checked or what the reservation is set at.  With that said, below will probably get you on the right path.

$VMs = Get-Cluster | Get-VM

Foreach ($VM in $VMs)

{

$configspec = New-Object VMware.Vim.VirtualMachineConfigSpec

$configspec.MemoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo

# This will uncheck the box.

$configspec.MemoryReservationLockedToMax = $false

# This will put the reservation back to 0

$configspec.MemoryAllocation[0].Reservation = 0

$VM.ExtensionData.ReconfigVM($ConfigSpec)

}

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos