This just came up the other day, see Win32::OLE made easy! and Scriptomatic.

Here is the code it produces for Win32_DisplayConfiguration:

use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my @computers = ("MYPC"); foreach my $computer (@computers) { print "\n"; print "==========================================\n"; print "Computer: $computer\n"; print "==========================================\n"; my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\ +root\\CIMV2") or die "WMI connection failed.\n"; my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Displ +ayConfiguration", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colItems) { print "BitsPerPel: $objItem->{BitsPerPel}\n"; print "Caption: $objItem->{Caption}\n"; print "Description: $objItem->{Description}\n"; print "DeviceName: $objItem->{DeviceName}\n"; print "DisplayFlags: $objItem->{DisplayFlags}\n"; print "DisplayFrequency: $objItem->{DisplayFrequency}\n"; print "DitherType: $objItem->{DitherType}\n"; print "DriverVersion: $objItem->{DriverVersion}\n"; print "ICMIntent: $objItem->{ICMIntent}\n"; print "ICMMethod: $objItem->{ICMMethod}\n"; print "LogPixels: $objItem->{LogPixels}\n"; print "PelsHeight: $objItem->{PelsHeight}\n"; print "PelsWidth: $objItem->{PelsWidth}\n"; print "SettingID: $objItem->{SettingID}\n"; print "SpecificationVersion: $objItem->{SpecificationVersion}\n" +; print "\n"; } }

I'm assuming (hopefully not wrongly) that you can set these properties as well as getting them.

--
John.


In reply to Re: Perl->WMI? (OT, I know) by jmcnamara
in thread Perl->WMI? (OT, I know) by Dismas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.