Kaseya Community

Reboot Virtual Guests and Host

  • I did not see anything like this posted, and I figured some poeple might be able to use it. It has been a big help for us.

    A quick script that can be used to shutdown the guest virtual machines. Then reboot the Host server, and when complete startup the guest machines. THIS HAS ONLY BEEN TESTED ON VMWARE SERVER 2.0!

    This is the batch file I wrote that will list the names of the guest servers. The cd path might need changed depending on your install location.

    cd "C:\Program Files (x86)\VMware\VMware Server"

    vmrun -h https://127.0.0.1:8333/sdk -T server -u administrator -p ""password"" list



    Code that will start the guest machines. The guestmachine/guestmachine.vmx will come from the above list command. Save as start.bat.
    cd "C:\Program Files (x86)\VMware\VMware Server"
    vmrun -h https://127.0.0.1:8333/sdk -T server -u administrator -p ""passwordstart "[standard] guestmachine/guestmachine.vmx"


    Now for the Kaseya script.
    IF True 
    THEN
    Execute Shell Command
    Parameter 1 : shutdown /s /f -m \\10.0.254.x -c "Host Server reboot"
    Parameter 2 : 0
    OS Type : 0
    Execute Shell Command
    Parameter 1 : shutdown /s /f -m \\10.0.254.x -c "Host Server reboot"
    Parameter 2 : 0
    OS Type : 0
    Schedule Script
    Parameter 1 : "Sample reboot script"
    Parameter 2 : 30
    Parameter 3 :
    OS Type : 0
    Schedule Script
    Parameter 1 : "calls second script to run above start.bat"
    Parameter 2 : 40
    Parameter 3 :
    OS Type : 0
    ELSE



    This might not be the cleanest way of doing it, but it works great and hope it helps out.

    Legacy Forum Name: Reboot Virtual Guests and Host,
    Legacy Posted By Username: JonJohnston
  • Thanks for posting that. I was just going to start working on that next Monday. Now I get part of my day back. Smile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: DavePurscell