Power Off/On for all AHV VMs

I have a home lab which sometimes gets loud, annoying, and warm. I needed to turn all my VMs off quickly before I brought down the cluster.  Basically, my wife wanted it off…

Power Off all VMs on Nutanix AHV

for vm_on_list in `acli vm.list power_state=on | grep -v ^'VM name' | awk '{print $1}'`; do acli vm.off $vm_on_list; done

Careful with the below as it will find all machines in a powered off state and power them on. I used this on my lab cluster and ended up turning on all my template sysprep’d VMs. Guess what I didn’t want on?

Power On all VMs on Nutanix AHV

for vm_off_list in `acli vm.list power_state=off | grep -v ^'VM name' | awk '{print $1}'`; do acli vm.on $vm_off_list; done

You May Also Like

About the Author: devmin

systems architect with interest in automation, k8s, linux, devops, bash, real estate, anonymity

1 Comment

Comments are closed.