Scripting automatic startup for virtual machines under Virtual Server

Scripting automatic startup for virtual machines under Virtual Server

  • Comments 2

Virtual Server allows you to configure virtual machines to startup automatically when the host system boots.  However in order to enable this feature you need to configure a user account to run the virtual machine under first (as when the host system boots there is no available user session to run the virtual machine under).  Below is a script that will configure a virtual machine to start automatically when the host system boots - if it was running when the host system shutdown:

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("VM Name")
objVM.RunAsDefinedAccount = True
result = objVM.SetAccountNameAndPassword("DOMAIN\Username","Password")
objVM.AutoStartAtLaunch = 2

If you want the virtual machine to always start (whether it was running before or not) you should set AutoStartAtLaunch to 1.

Cheers,
Ben

Leave a Comment
  • Please add 1 and 3 and type the answer here:
  • Post
  • Excellent, but how do I use it Virtualguy?

    Thanks
  • Hello!

    This seems interesting and exactly what I am looking for now. But would it work in Windows Hyper-V Server 2008 R2 ?

Page 1 of 1 (2 items)