Using Set and Get ConfigurationValue with Virtual Server

Using Set and Get ConfigurationValue with Virtual Server

  • Comments 3

Last week I showed you how to use GetConfigurationValue and SetConfigurationValue to change the BIOS configuration for a virtual machine.  This week I would like to continue working with these API's and provide some more samples of how they can be used.  Get and Set ConfigurationValue allow you to get and set any value in the virtual machine configuration file.  This can be very useful for getting access to some of the more esoteric features of Virtual Server for which a direct COM interface does not exist.  The script below uses these APIs to check and set the mouse integration setting for a virtual machine (as discussed here):

Set vs = CreateObject("VirtualServer.Application")
set vm1 = vs.FindVirtualMachine(WScript.Arguments(0))

key = "integration/microsoft/mouse/allow"
currentValue = vm1.GetConfigurationValue(key)

Wscript.echo "The state of mouse integration on " & WScript.Arguments(0) & " is: " & currentValue

if currentValue then
 newvalue = false
Else
 newvalue = true
End if

result = vm1.SetConfigurationValue(key, cbool(newvalue))

Wscript.echo "The state of mouse integration on " & WScript.Arguments(0) & " has been set to: " & newvalue

This script takes the virtual machine name as a command line parameter, gets the current value for the mouse integration setting, informs the user of the current value, changes the configuration value to be opposite what it used to be, and then informs the user of this change.

Cheers,
Ben

Leave a Comment
  • Please add 5 and 8 and type the answer here:
  • Post
  • And the name is just an XPath into the .vmc XML, I guess?
  • You might also do a post on how to store user data in the VMC...

    -Mike
  • Jonothan -

    Correct.

    Cheers,
    Ben
Page 1 of 1 (3 items)