I'm working on a perl script that is used to check whether a number of services are running. To achieve this, we are using WMI to query remote Windows servers:
my $WMI_locator = Win32::OLE->new('WbemScripting.SWbemLocator');
$WMI_locator->{Security_}->{AuthentificationLevel} = 6;
my $computer = $WMI_locator->ConnectServer($server, 'root\cimv2', $adminuser, $adminpasswd);
my $services = $computer->ExecQuery('SELECT * FROM Win32_Service', 'WQL', $flag_return_immediately | $flag_forward_only);
This code snippet works perfectly when executed on my dev laptop. However, strange things happen when I try to run it from the production server: for some remote windows computers, I can only get about half the Services list.
I have looked into this, and found that the issue is only happening on servers with a lot of services (around 150), and for which there's a difference in the average ping (~60ms on local, ~215ms on production server). The issue seems to come from WMI rather than perl; I have tried to query the servers from the DOS command line, and I'm getting an error when trying to get the services, although querying the CPU works just fine :
E:\>wmic /NODE:server /USER:adminuser /PASSWORD:adminpasswd SERVICE GET Caption, State
Node - server
ERROR:
Code = 0x800706be
Description = The remote procedure call failed.
Facility = Win32
E:\>wmic /NODE:server /USER:adminuser /PASSWORD:adminpasswd CPU GET Name, Status
Name Status
Intel(R) Xeon(R) CPU X5650 @ 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 @ 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 @ 2.67GHz OK
Intel(R) Xeon(R) CPU X5650 @ 2.67GHz OK
Given that, I'm guessing the issue is network related, but we're now delving in a country I'm not familiar with. Is there some parameter I have missed and/or something wrong with the way I'm doing things?
Thanks for your answers!
This error is almost always (although not exclusively) caused by multiple instances of different versions of SQL server. To narrow down the problem try WMI Diagnostic Utility, it's designed to help with this type of problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With