RE: WIN32::OLE WMI Out params
Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE WMI Out params
I haven't followed your thread closely, but it seems like the relevant bits from your first link are these: my $objSecDescriptor = Win32::OLE::Variant- new (VT_DISPATCH|VT_BYREF); my $retval = $objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor); ..which seems to be filling the $objSecDescriptor with an out param. If your out param is an array, you might need to add VT_ARRAY to the variant flags when you create it. Does something like that work for you ? -Mike Michael wrote: Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. use Win32::OLE::Variant; my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
-Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Ellery Sent: Friday, December 04, 2009 11:59 AM To: Michael Cc: perl-win32-users@listserv.ActiveState.com Subject: Re: WIN32::OLE WMI Out params I haven't followed your thread closely, but it seems like the relevant bits from your first link are these: my $objSecDescriptor = Win32::OLE::Variant- new (VT_DISPATCH|VT_BYREF); my $retval = $objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor); ..which seems to be filling the $objSecDescriptor with an out param. If your out param is an array, you might need to add VT_ARRAY to the variant flags when you create it. Does something like that work for you ? -Mike Michael wrote: Hi Steven, Well I tried your suggestion and I think that the Win32::OLE::Variant module might be the solution, as I have found some other examples where WMI [out] and variants are used. http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set- folder-level-permissions-16930-1/ http://www.perlmonks.org/?node_id=325823 However I'm in way over my head here, so unless someone could cut it out in pieces , I don't think that I'll get any further. /Michael On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net wrote: Below... -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Michael Sent: Thursday, December 03, 2009 6:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: RE: WIN32::OLE WMI Out params When troubleshooting OLE issues, it is best to have the following code after each OLE command... If (Win32::OLE- LastError() != 0) { print error calling blah: . Win32::OLE- LastError() . \n; exit 0; } ...Or something similar, so you can see what OLE had issues with (if anything). It might lead you in a direction that fixes it. Steven Added to the script, but no issues reported. /Michael Well, then my next guess is the use of the Variant module (because no error is thrown from OLE). Some OLE calls require to be cast of a certain type before they work. my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); My apologies here.. I think that I misstated the way to call it. Put this at the top somewhere... use Win32::OLE::Variant; Add the following before your GetChildNodes call. Thanks go to Michael Ellery for making me see that mistake as I did not test this code before sending it off. my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); By adding this before your GetChildNodes call, you should be all set (Variant-wise) However, before you give up after trying the above call (if it does not work as stated above), I would replace: VT_ARRAY|VT_VARIANT With VT_VARIANT And also try.. (if the previous does not work) VT_ARRAY|VT_BSTR And lastly try his example from the SecurityDescriptor call.. VT_DISPATCH|VT_BYREF ...in my code above. As well, you might try sticking the VT_BYREF as another ORed option to each of the above examples like in Michael Ellery's example.. i.e. VT_ARRAY_|VT_BSTR|VT_BYREF or VT_VARIANT|VT_BYREF or VT_ARRAY|VT_VARIANT|VT_BYREF HTH Steven #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of VT_ARRAY|VT_VARIANT #then my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); Play around with this... I'm not the greatest Variant script writer here, to know exactly which combination will work (if this is it) based on the object type as I've only run into this a few times before, but you can get examples from your perl install here (depending on your perl build version) of similar options to try and all the VT_* types: C:\Perl\html\lib\Win32\OLE\Variant.html HTH P.S. I googled OV_NodeGroup and found someone else with your same problem on an HP board (or so it seems). :( Steven ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WIN32::OLE WMI Out params
Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: WIN32::OLE WMI Out params
Michael wrote: Okay - Just to sum up the whole thing. The original VBScript EOF; Option Explicit Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes, objItem Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data) Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True) WScript.Echo Child Group Count: objChildGroups vbCrLF For Each objItem In arrNodes WScript.Echo Name: objItem.Name Next EOF Returns the following: Child Group Count: 25 Name: {36716FD8-E600-46FB-90CA-1263E0C62509} Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25} Name: {3E575181-0225-4553-9722-46F841B9FA76} Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4} Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281} Name: OpenView_AIX Name: OpenView_External Name: OpenView_HPUX Name: OpenView_Linux Name: OpenView_NNM Name: OpenView_OpenVMS Name: OpenView_OpenVMS(itanium) Name: OpenView_SNMP Name: OpenView_Solaris Name: OpenView_Tru64 Name: OpenView_Unknown Name: OpenView_Windows2000 Name: OpenView_WindowsNT Name: OpenView_WindowsServer2003 Name: OpenView_WindowsServer2008 Name: OpenView_WindowsVista Name: OpenView_WindowsXP Name: Root_Special Name: Root_Unix Name: Root_Windows And the Perl-Script with the modification EOF; #!perl use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Data::Dumper; my $objWMIService = Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die WMI connection failed.\n; if (Win32::OLE- LastError() != 0) { print Error calling GetObject: . Win32::OLE-LastError() . \n; exit 0; } my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup); if (Win32::OLE- LastError() != 0) { print Error calling Get: . Win32::OLE-LastError() . \n; exit 0; } my $objGetRoot = $objOV_NodeGroup-GetRoot(); if (Win32::OLE- LastError() != 0) { print Error calling GetRoot: . Win32::OLE-LastError() . \n; exit 0; } my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True); if (Win32::OLE- LastError() != 0) { print Error calling GetChildNodeGroups: . Win32::OLE-LastError() . \n; exit 0; } print Child Group Count: . $objChildGroups . \n; print Dumper($nodes); foreach my $objItem (in $nodes) { print 'Name: ' . $objItem-{Name} . \n; } #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105: The server threw an exception ##in METHOD/PROPERTYGET GetChildNodeGroups #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0); Returns ##Child Group Count: 25 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' ); ##Not a HASH reference at GetChildNodeGroups.pl line 46. Does any of this, make any sense to you guys? /Michael so, it looks like your Dumper statement is indicating a valid object in most cases. I think the problem on your loop is that you are using the 'in' adapter,