Skip to content

Instantly share code, notes, and snippets.

@jbarber
Created July 5, 2010 13:42
Show Gist options
  • Save jbarber/464358 to your computer and use it in GitHub Desktop.
Save jbarber/464358 to your computer and use it in GitHub Desktop.
Set VM advanced options (stop ballooning)
# VMware: set the advanced configuration option sched.mem.maxmemctl to zero to prevent ballooning
function deballoon ($vmname) {
# Set "sched.mem.maxmemctl" to 0
$opt = new-object Vmware.Vim.OptionValue -Property @{ Key = "sched.mem.maxmemctl"; Value = 0 }
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += $opt
# Use a filter to find a particular VM
$vm = get-view -viewtype "VirtualMachine" -filter @{ "Name" = $vmname }
# And update the config on the server
$vm.ReconfigVM( $vmConfigSpec )
}
connect-viserver -server virtualcenter -credential (Get-Credential (Get-Item env:username).value)
deballoon( "vm-name" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment