Stupid Script

I just cobbled this script together to make starting up VirtualBox VM’s a little easier when remote.

for a in `vboxmanage list vms | sed 's/^"\(.*\)".*/\1/'`; \
do echo $a && vboxmanage showvminfo $a | grep -c "running (since" ;done

This will give you a list of all of your VMs. Followed by a 1 if it is powered on or a 0 if it isn’t. If your VM name contains a space, this won’t work. In that case, the following will give you just the list:

vboxmanage list vms

You can then run the following to get all of the information and grep out the “since”

vboxmanage showvminfo "My VM"