Quote:
Originally Posted by aigles
Code:
foreach($computer, @raw_list)
{
$objWMIService = Win32::OLE->GetObject
("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
$colItems = $objWMIService->ExecQuery
("SELECT * FROM Win32_OperatingSystem","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems)
{
print "Caption: $objItem->{Caption}\n";
print "CSD Version: $objItem->{CSDVersion}\n";
print "CS Name: $objItem->{CSName}\n";
print "Name: $objItem->{Name}\n";
print "Service Pack Major Version: $objItem->{ServicePackMajorVersion}\n";
print "System Directory: $objItem->{SystemDirectory}\n";
print "Windows Directory: $objItem->{WindowsDirectory}\n";
print "\n";
}
}
|
I tried that and get a 255 error.
if i change it to foreach(@raw_list) or foreach($computer) i get an error 9
here is the error, substitute 255 for the 9
WMI connection failed.
host1
host2
host3
Exit code: 9 , 0009h
I'm sure it is with the array, but damn if i can figure it out!

Where do i find the system error codes such as 9 or 255?
EDIT: ok, i ran the script with perl -w and this is what i received
Odd number of elements in hash assignment at retina.pl line 21, <DATA> line 3.
Win32::OLE(0.1707) error 0x80041021
after character 0 in "winmgmts:\\c:\list\hosts.txt
\root\CIMV2" at retina.pl line 30
eval {...} called at retina.pl line 30
WMI connection failed.
so basically, what i gather from this is that it may not even be connecting to the WMI service to begin with? And for some reason it is reading what is supposed to be a
hostname as the literal filename and path. Am i on the right track here?
thank you