Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

WMI SubclassesOf $WMIServices not giving all the objects ?

by secret (Beadle)
on Jan 23, 2006 at 11:36 UTC ( [id://524898]=perlquestion: print w/replies, xml ) Need Help??

secret has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I'm not very good at windows object and i encounter a problem when using Win32::OLE .

Here is what i do:

use Win32::OLE qw (in); my $Computer="."; my $WMIServices= Win32::OLE->GetObject("winmgmts:\\\\" . $Computer . " +\\root\\cimv2"); my $test=SubclassesOf $WMIServices; use Data::Dumper; print Dumper($test);
This gives the following result :
$VAR1 = bless( {
                 'Count' => 626,
                 'Security_' => bless( {
                                         'ImpersonationLevel' => 3,
                                         'AuthenticationLevel' => 6,
                                         'Privileges' => bless( {
                                                                  'Count' => 0
                                                                }, 'Win32::OLE' )
                                       }, 'Win32::OLE' )
               }, 'Win32::OLE' );

The problem is that when i look at the properties of $test with the Visual Basic Espions I see a whole lot of other objects, named "Item 1" to "Item 256" . Here's what i do in VB :

Set test = objWMIService.SubclassesOf()
My question is what are those Item objects and why am i not seeing them with Perl ?

Thanks for your explanations :)

Replies are listed 'Best First'.
Re: WMI SubclassesOf $WMIServices not giving all the objects ?
by BrowserUk (Patriarch) on Jan 23, 2006 at 12:03 UTC

    The return from SubclassesOf is a collection. To acess the members of the collection, use the in keyword, which you are importing with your

    use Win32::OLE qw (in);
    , in conjunction with a for loop.
    #! perl -slw use strict; use Win32::OLE qw (in); use Data::Dumper; my $Computer = "."; my $WMIServices = Win32::OLE->GetObject("winmgmts:\\\\" . $Computer . +"\\root\\cimv2"); my $test = $WMIServices->SubclassesOf; for my $sub ( in $test ) { print Dumper $sub; }

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: WMI SubclassesOf $WMIServices not giving all the objects ?
by marto (Cardinal) on Jan 23, 2006 at 12:07 UTC
    Hi secret,

    Try:
    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Win32::OLE qw (in); my $Computer="."; my $WMIServices = Win32::OLE->GetObject("winmgmts:\\\\" . $Computer . +"\\root\\cimv2"); my $WMIClasses = $WMIServices->SubclassesOf; foreach my $objItem (in $WMIClasses) { print Dumper($objItem); }

    Hope this helps.

    Martin

    Update: added formatting.
Re: WMI SubclassesOf $WMIServices not giving all the objects ?
by secret (Beadle) on Jan 23, 2006 at 13:08 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://524898]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found