#!/bin/bash
#
VMOWNER=mib

for VM in $(su - $VMOWNER -c "VBoxManage list vms" |awk '{print $1}' | xargs)
    do
       AUTOSTART=$(su - $VMOWNER -c "VBoxManage showvminfo $VM | grep -F 'Autostart Enabled:'" | awk '{print $3}' | xargs)  

       echo $VM - $AUTOSTART
         if [[ $AUTOSTART == "enabled" ]]
            then
                echo "Starting VM: " $VM
		su - $VMOWNER -c "VBoxManage startvm $VM --type=headless"		
         fi

    done
