Coding Corner: A basic Virtual Server script

Coding Corner: A basic Virtual Server script

Rate This
  • Comments 4

Due to reader demand - I am going to try and start a 'coding corner' where I talk about programming to Virtual Server's COM API.  For those that don't know - Virtual Server is completely driven via COM - and anything that you want to do with Virtual Server can be done programatically.

We are going to start things off slowly with a very simple VBScript.  This script will:

  1. Create a connection to Virtual Server
  2. Get a collection of all the virtual machines
  3. Iterate over the collection and display some basic information about each virtual machine

'Script Begins

On Error Resume Next

'Connect to Virtual Server
Set virtualServer = CreateObject("VirtualServer.Application")

'Get collection of virtual machines
set vmCollection = virtualServer.VirtualMachines

'Iterate over the virtual machines and display data
For Each vm in vmCollection
    Wscript.Echo "=============================="
    Wscript.Echo "Name: " & vm.Name
    Wscript.Echo
    Wscript.Echo "Notes: " & vm.Notes
    Wscript.Echo
    Wscript.Echo "Configuration File: " & vm.File
    Wscript.Echo "Saved state file: " & vm.SavedStateFilePath
    Wscript.Echo
    Wscript.Echo "Guest OS: " & vm.GuestOS
    Wscript.Echo "Memory: " & vm.Memory
    Wscript.Echo "Undo disks enabled: " & vm.Undoable
    Wscript.Echo
    Wscript.Echo "=============================="

Next

'Script Ends

As you can see this is really quite simple - but don't worry - we will get more complex as we go on.

Cheers,
Ben

Leave a Comment
  • Please add 5 and 6 and type the answer here:
  • Post
  • Corner....you aren't down under anymore....
  • Great!
    This is going to be very interesting! ;)

    Cheers!
  • Heh heh.. Fixed the spelling...
  • ;-)
Page 1 of 1 (4 items)