How can I set the memory reservation on all VMs to “0”?
I’m trying to write a script that will set the memory reservation on all of the guest VMs in a cluster to “0”. We were reserving too much memory, and this setting should allow the VMWare facilities to manage the memory reservations for me. I have hundreds of VMs to update, so I can’t do it by hand. I’m hoping it can be done with the CLI.
1 2 3 4 |
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.memoryAllocation = New-Object VMware.Vim.ResourceAllocationInfo $spec.memoryAllocation.Reservation = 0 Get-Cluster "YOUR_CLUSTER" | Get-VM | Get-View -Property Config.MemoryAllocation | %{$_.ReconfigVM_Task($spec)} |