Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How do I get past "WMI Connection failed" errors

by StarkRavingCalm (Sexton)
on Feb 12, 2009 at 19:10 UTC ( #743434=perlquestion: print w/ replies, xml ) Need Help??
StarkRavingCalm has asked for the wisdom of the Perl Monks concerning the following question:

Hoping this is an easy one...

I have a script that I am using to query Windows machines for Hotfixes. I am running it as domain admin. When it connects to a machine, I get the data I am looking for. But, if it hits a machine that is down (I verify with a ping), I get "WMI Connection failed" errors and then it stops. I have a warn statement in there but it does not continue.

Here is the relevant data in the script.(The script itself is HUGE as it does some munging at the end before it writes to a file)

my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\ro +ot\\CIMV2") or warn "WMI connection failed.\n"; my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Quick +FixEngineering", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly);

Can anyone help me get past these errors?

Comment on How do I get past "WMI Connection failed" errors
Download Code
Re: How do I get past "WMI Connection failed" errors
by Corion (Pope) on Feb 12, 2009 at 19:15 UTC

    Most likely you can catch the error using an eval block. Otherwise, I'd just ping the machine before trying to connect to it:

    select responsetime from Win32_PingStatus where Address = '192.168.1.1'

      That could work as a temporary work around.

      Right now I am reading each machine name from an array, but I ultimately want reading each server in real time from the domain.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://743434]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-07-26 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls