Scripting starting a network under Virtual Server


I have had quite a number of people asking me how you script a start up order for virtual machines under Virtual Server 2005. A good example of this is to make sure your DC is online before your Exchange Server starts up. There are a few ways you can do this…


Ben Armstrong has provided a couple of solutions on his blog: http://blogs.msdn.com/virtual_pc_guy/archive/2005/09/29/473898.aspx


I have re-written this one to work with the scripts I have been posting recently…


In this solution we will us the heartbeat function to see when the machine is online:


‘script starts


On Error Resume Next


‘This script is designed to start up the first Virtual Machine (vmname1) and wait until we get a heartbeat (i.e. it is online) before starting the second machine.
‘There are 3 parameters: vmName1, vmName2 and vmHost


‘ Get / Set arguments
vmName1=WScript.Arguments(0)
vmname2=WScript.Arguments(1)
‘vsHost = WScript.Arguments(2)
vsHost = “localhost”


‘ Connect to Virtual Server
Set virtualServer = CreateObject(“VirtualServer.Application”,vsHost)


‘ Create virtual machine objects
Set vm1 = virtualServer.FindVirtualMachine(vmName1)
Set vm2 = virtualServer.FindVirtualMachine(vmName2)


‘Start first virtual machine
vm1.startup


‘Ignore errors 
On Error Resume Next


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


‘Listen to error messages again
On Error GoTo 0


‘Start second virtual machine
vm2.startup


‘Script ends


 


Comments (2)

  1. John Kot says:

    In your presentation on Oct 17/05 you showed several VB scripts. Can you make they available. Thanks.

  2. Joseph Zinguer says:

    Bruce:

    Could you please publish on this blog your Oct.17, 2005 presentation with VM2005 scripts?

    Thank you!

    zinguer@rogers.com