I am using PowerCLI to "PowerOff" VMs when there is a certain event detected. When this even happens, the only thing we can do is to power off the VM and power it on again.

I use Stop-VM -VM xxxx -Kill -Confirm:$false to power off the VM but I noticed that HA will restart the VM after the VM powered off.

But if I manually do "Power off" in vSphere GUI on this VM when HA is turned on, it stays "powered off"

Any idea why HA will start a VM which "powered off" by PowerCLI? or Stop-VM is not the command for "Power Off"?


Have you tested this without -Kill? From the Stop-VM cmdlet reference:

Indicates that you want to stop the specified virtual machines by terminating their processes running on the ESX. You can use this parameter to stop a virtual machine that is not responding and cannot be stopped or restarted in other ways. To use the Kill parameter, you need to have a direct connection to ESX 4.1 or later.

Terminating the process directly on the host sure sounds like an event that should trigger HA. I think I would take a tiered approach to this:

# Some condition happens, ask nicely.
Shutdown-VMGuest -VM xxxx -Confirm:$false
# Ask less nicely.
Stop-VM -VM xxxx -Confirm:$false
# A last ditch effort.
Get-VM xxxx | Set-Vm -HARestartPriority Disabled -Confirm:$false
Stop-VM -VM xxxx -Kill -Confirm:$false
  • Shutdown-vm is not an option because it will go through windows shutdown process, thats where the issue is - "server hangs, no responding". the only option i have is to power off vm from host. I think actually it is better for us if it can be restarted by HA itself, so I dont have to run one more command to start the vm. – Root Loop Jan 24 '18 at 14:13
  • It's helpful if you add your specific requirements, restrictions and expectations to your original question. – jscott Jan 24 '18 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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