The following is a code example using Perlscript:
More examples can be found at:
http://www.planetmps.com/
use Win32;
use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
$tempstr;
my $Locator = Win32::OLE->new("WbemScripting.SWbemLocator");
my $Services = $Locator->ConnectServer(".", "root\CIMV2\sms");
my $ob = $Services->Get("Win32_Process");
my $objset = $ob->Instances_;
foreach $obj (in $objset)
{
$propSet = $obj->{Properties_};
foreach $prop (in $obj->Properties_)
{
if(ref($prop->{Value}) ne "null")
{
if(ref($prop->{Value}) eq "ARRAY")
{
$tempstr = $tempstr . $prop->Name . ": " . join("," , (in $prop->{value})) . "\n";
}
else
{
if ($prop->CIMType == 101)
{
$tempstr = $tempstr . $prop->Name . ": " . convertDate($prop->{value}) . "\n";
}
else
{
$tempstr = $tempstr . $prop->Name . ": " . $prop->{value} . "\n";
}
}
}
}
print $tempstr;
last;
}
Sub convertDate()
{
my ($cdater) = @_;
if($cdater == "")
{
}
else
{
$tstr = substr($cdater, 4,2) . "/" . substr($cdater, 6,2) . "/" . substr($cdater, 0,4) . " " . substr($cdater, 8,2) . ":" . substr($cdater, 10,2) . ":" . substr($cdater, 12,2);
return $tstr;
}
}
No comments:
Post a Comment