Refactor VirtualMachine command methods

Programmatically define these as they are all very similar code