Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to automate some tests that each time the number of CPUs and memory size of the Virtual Machine is changed. I'm wondering how to change them from command line? It seems starting and stopping guest os can be done from ESXi host's command line. But is there a command to change the virtual machine's #CPUs and memory size? Or in general, can this be done in a command line manner?

share|improve this question
up vote 1 down vote accepted

The easiest way to do this would be through PowerCLI, which is a PowerShell plugin for vSphere. With that you can use the Set-VMResesourceConfiguration cmdlet to modify the resource configuration of your guest machines.

share|improve this answer
Thank you DKNUCKLES! Is there a similar utility for the Linux system? The environment I have is Linux, it'll be a lot easier if I can launch something directly from current box. – duyt Sep 14 '12 at 16:42
You can install a virtual appliance from Double Cloud. Can't vouch for this as I have no experience, but the link is here -… – DKNUCKLES Sep 14 '12 at 17:03
vCLI is probably what you are looking for if you want to stay in the Linux world: – JakeRobinson Sep 14 '12 at 19:51

DKNUCKLES was correct with PowerCLI, but the actual command to do what you need is Set-VM


$vm = Get-VM "My VM"
$vm | Stop-VM # Or use Shutdown-VMGuest to have the Guest OS do a clean shutdown
$vm | Set-VM -NumCPU 4 -MemoryMB 4096
$vm | Start-VM

Set-VMResourceConfiguration changes the resource reservations for the VM.

share|improve this answer
Thanks Jake, This works! – duyt Sep 16 '12 at 1:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.