Hi
PowerCLI C:\> Get-VM xxx | Get-VMResourceConfiguration | Select-Object Name, CpuReservationMhz, MemReservationMB
Name CpuReservationMhz MemReservationMB
---- ----------------- ----------------
0 8192
i was able to remove cpu reservation with below
foreach ($line in $csv) | ||||
{ | ||||
Get-VM $($line.name) |% {Get-View $_.ID} | % {
$spec = new-object VMware.Vim.VirtualMachineConfigSpec;
$spec.CPUAllocation = $_.ResourceConfig.CpuAllocation
$spec.CpuAllocation.Reservation = 0;
$_.ReconfigVM_Task($spec)
}
}
but it does not work for memory
for me even below did not work
1
|
Get-VM|Get-VMResourceConfiguration|where{$_.MemLimitMB-ne'-1'}|Set-VMResourceConfiguration-MemLimitMB$null
|
below did not work too
$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)
}
i tried below too
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.memoryReservationLockedToMax = $true
(Get-VM xxx).ExtensionData.ReconfigVM_Task($spec)
no luck
Please help