Scripting launch dependencies under Virtual Server

  • Comments 3

With more complex virtual machine configurations you might find that you have dependencies on the order in which virtual machines should be launched (for instance one virtual machine may be a domain controller - while the other virtual machines are members of that domain).  There are two ways to handle this in an automated fashion under Virtual Server.  One is to set the virtual machines to start automatically and set appropriate start delay values for each virtual machine.  The second option is to use a script like this:

' || Script begins
' Connect to Virtual Server

Set virtualServer = CreateObject("VirtualServer.Application")

' Create virtual machine objects
Set vm1 = virtualServer.FindVirtualMachine("Virtual Machine 1")
Set vm2 = virtualServer.FindVirtualMachine("Virtual Machine 2")

'Start first virtual machine

'Ignore errors on the next little section
On Error Resume Next

'Loop until vm1 returns a heartbeat
while not vm1.GuestOS.IsHeartbeating
 wscript.sleep 500

'Listen to error messages again
On Error GoTo 0

'Start second virtual machine

' || Script ends

This script launches the first virtual machine and then waits for the virtual machine heartbeat to return before launching the second virtual machine.  This is a very robust solution as the virtual machine heartbeat will not return until most of the services are up and running on the virtual machine.  It should be noted that it is important to handle errors in the middle of this script as until the virtual machine has loaded the Virtual Machine Additions component requesting the value of the heartbeat will return an error.


Leave a Comment
  • Please add 2 and 5 and type the answer here:
  • Post
  • I am having trouble running this script can you help? I am new to running scripts so sory for the lack of knowledge.
  • What problems are you having?

  • We have just combined something similar into a command line tool (and windows app) that you can use to defrag and backup a complete raft of Virtual Machines.

    It will save state / shut down defrag / backup all associated VMC, VHD files then restore to its previous state.

Page 1 of 1 (3 items)

Scripting launch dependencies under Virtual Server