Hyper-V Program Manager
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 ServerSet virtualServer = CreateObject("VirtualServer.Application") ' Create virtual machine objectsSet vm1 = virtualServer.FindVirtualMachine("Virtual Machine 1")Set vm2 = virtualServer.FindVirtualMachine("Virtual Machine 2") 'Start first virtual machinevm1.startup 'Ignore errors on the next little sectionOn Error Resume Next 'Loop until vm1 returns a heartbeatwhile not vm1.GuestOS.IsHeartbeating wscript.sleep 500wend 'Listen to error messages againOn Error GoTo 0 'Start second virtual machinevm2.startup '' || Script ends
' || Script begins'' Connect to Virtual ServerSet virtualServer = CreateObject("VirtualServer.Application")
' Create virtual machine objectsSet vm1 = virtualServer.FindVirtualMachine("Virtual Machine 1")Set vm2 = virtualServer.FindVirtualMachine("Virtual Machine 2")
'Start first virtual machinevm1.startup
'Ignore errors on the next little sectionOn Error Resume Next
'Loop until vm1 returns a heartbeatwhile not vm1.GuestOS.IsHeartbeating wscript.sleep 500wend
'Listen to error messages againOn Error GoTo 0
'Start second virtual machinevm2.startup
'' || 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.
Cheers,Ben