Page 1 of 1 1
Topic Options
#177797 - 2007-07-11 07:48 PM Scripting Virtual Server - Bug?
PrebenJ Offline
Just in Town

Registered: 2005-03-27
Posts: 4
Loc: Denmark
*** Ruud - is this a COM bug or "lack-of-feature" ? *** (Shawn)

I am trying to use Kixtart to script Microsoft Virtual Server 2005 R2 but it simply doesn't work with Kixtart at all!

The following VBS code works just fine:

 Code:
Set objVS = CreateObject("VirtualServer.Application")
Set vm = objVS.FindVirtualMachine("Server1")
Wscript.Echo "Name=" & vm.Name


But the Kixtart version:

 Code:
$objVS = CreateObject("VirtualServer.Application")
$vm = $objVS.FindVirtualMachine("Server1")
? "Name=" + $vm.Name


Always returns -2147352567 which translates into 80020009 which as far as I can see is some sort of "Exception occurred" or if I take the 9 and type NET HELPMSG on it says "The storage control block address is invalid".

The CreateObject itself doesn't return an error but as soon as I try to do something with it @ERROR is set to the value mentioned above.

Top
#177801 - 2007-07-11 08:16 PM Re: Scripting Virtual Server [Re: PrebenJ]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I dont have this object, but try this:

Can you try some debugging lines and report back ?

$objVS = CreateObject("VirtualServer.Application")

?"FindVM=" + VarTypeName($objVS.FindVirtualMachine)

?"Server1=" + VarTypeName($objVS.FindVirtualMachine("Server1"))

? "Name=" + $vm.Name

Top
#177806 - 2007-07-11 08:29 PM Re: Scripting Virtual Server [Re: Shawn]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that will error out on the last line.
but the debug stuff is already shown on the console screen at that time.
_________________________
!

download KiXnet

Top
#177810 - 2007-07-11 09:22 PM Re: Scripting Virtual Server [Re: Lonkero]
PrebenJ Offline
Just in Town

Registered: 2005-03-27
Posts: 4
Loc: Denmark
Hi Shawn!

The result of the debug code is:

FindVM=Empty
Server1=Empty

Top
#177813 - 2007-07-11 09:36 PM Re: Scripting Virtual Server [Re: PrebenJ]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Whats the error code after the call to FindVirtualServer ? Might want to add in the WrapAtEol to show those long COM messages.

$= SetOption("WrapAtEol", "On")

$vm = $objVS.FindVirtualMachine("Server1")

? "ERROR @ERROR - @SERROR"

Top
#177815 - 2007-07-11 09:48 PM Re: Scripting Virtual Server [Re: Shawn]
PrebenJ Offline
Just in Town

Registered: 2005-03-27
Posts: 4
Loc: Denmark
ERROR -2147352567 - COM exception error "FindVirtualMachine" ((null) - (null)) [-2147352567/80020009]
Top
#177817 - 2007-07-11 10:12 PM Re: Scripting Virtual Server [Re: PrebenJ]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well that's the strangest thing. Should work - it appears like VBS COM is "doing something" that Kixtart is not. Think I may have found out what the difference is - here's a quote from MSDN:

 Quote:

Connecting to the Virtual Server COM Object

The Virtual Server programming interface is a standard COM object. Before any of the interfaces are accessed, the COM layer is initialized, the default security access level is set, and a pointer to the main IVMVirtualServer object is obtained. All other Virtual Server objects are accessed through this primary interface.

The Virtual Server COM interfaces can only be accessed if the COM Security level is set to Impersonation level or higher. By default, COM uses the Identification security level if no level is explicitly specified. To set the COM security level, the user's program should make a call to CoInitializeSecurity immediately after the initial CoInitializeEx call and before any of the Virtual Server's interfaces are accessed.


Its the second paragraph that may apply. Not sure if Ruud (developer) is calling the CoInitializeSecurity function on created com objects or not.

I'm going to move this thread to BETA and hopefully Ruud can respond.


Top
#177820 - 2007-07-11 10:22 PM Re: Scripting Virtual Server [Re: Shawn]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Moved topic to Beta and flagged Ruud in first post.
Top
#179224 - 2007-08-13 11:44 AM Re: Scripting Virtual Server [Re: Shawn]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Thanks for this report. Haven't seen this problem before, I'll dive into it and let you know what I find. Cheers, Ruud
Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 675 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.069 seconds in which 0.035 seconds were spent on a total of 13 queries. Zlib compression enabled.