There are two different powerOn APIs:
- vim.VirtualMachine.powerOn: This method is used by scheduled tasks to power on a virtual machine. This method may fail when used for DRS-facilitated power on tasks, because it cannot act on proposed DRS recommendations that would require powering on multiple virtual machines. For more information, see the VMware vSphere API Reference Documentation.
- vim.Datacenter.powerOnVm: This method is invoked when you manually power on a virtual machine through the UI. This method succeeds for DRS-facilitated power on or vmotion tasks, because it is capable of acting on proposed DRS recommendations that affect multiple virtual machines. This includes performing a vMotion on other virtual m achines or powering on additional hosts in order to balance a load. For more information, see the VMware vSphere API Reference Documentation.
The first API is being used by scheduled tasks, and this is why powering on a virtual machine through a scheduled task seems to fail. Do not use scheduled tasks to power on virtual machines if you would like DRS to consider load-balancing operations. Instead, develop your own SDK client that uses the second API for power on operations. For more information, see the VMware vSphere Web Services SDK Documentation.