Tuesday, July 13, 2010

Perl: Using WMI in Perl

Problem Statement: Using WMI in Perl

Solution:

use Win32::OLE;

$instances = Win32::OLE->GetObject("winmgmts:\\\\localhost\\root\\CIMV2")->InstancesOf(Win32_LogicalDisk) or die "Cant access WMI";

for my $proc (in $instances)

{

printf "%5d %7d \n", $proc->{ProcessId}, $proc->{WorkingSetSize};

}

More examples on: http://www.perlmonks.org

No comments: