TechTutorials - Free Computer Tutorials  







VBScript - Start all Virtual Machines on a Virtual Server 
 


Added: 11/22/2005, Hits: 4,299, Rating: 0, Comments: 0, Votes: 0
Add To Favorites | Comment on this article
The management console for Virtual Server is a web based tool. This poses a problem is so far as you cannot multiple select tasks for different objects in it. For example, I would like to be able to start up, shut down, etc, etc all my virtual servers at once. I would also like other collegues to be able to perform some of these example functions, without having to familiarise themselves with the Web based management console.

The answer of course is a VBScript....

Code :

On error Resume next
set ObjVS = CreateObject("virtualserver.application")

Set objVMColl = objvs.VirtualMachines
If objVMColl.Count = 0 Then
Wscript.echo "There are no Virtual Machines detected on this server"

Else

wscript.echo "Virtual Machines: " & objVMColl.Count
For each objVM in objVMColl

wscript.echo "Started: " & objVM.Name
Set subVirtualServer = CreateObject("VirtualServer.Application")
set vmVar = subVirtualServer.FindVirtualMachine(objVM.Name)
vmVar.Startup

Next
End If


Do forgive the untidiness of the script - but it does the job.

This is the same as the above script, but now with a nice pop up giving you a Yes or No option for each Virtual machine discovered.

Code :

On error Resume next
set ObjVS = CreateObject("virtualserver.application")

Set objVMColl = objvs.VirtualMachines
If objVMColl.Count = 0 Then
Wscript.echo "There are no Virtual Machines detected on this server"

Else
For each objVM in objVMColl

StrMSG="Would you like to turn on Virtual Machine: " & objVM.name
If msgbox (StrMSG, vbYesNo, "Start Virtual Machines")=vbYes THen


Set subVirtualServer = CreateObject("VirtualServer.Application")
set vmVar = subVirtualServer.FindVirtualMachine(objVM.Name)
vmVar.Startup
End If

Next
End If


Again, may be untidy, but it works. Will only work on the Virtual Server still at present. Will look into the COMDCOM stuff soon.





Comments (0)

Be the first to comment on this article


Related Items








7 Seconds Resources, Inc.




IT Showcase