Reputation: 4198
I have an enterprise of around 3,500 PCs I have to manage with Microsoft's System Center Configuration Manager (SCCM). The SCCM client heavily depends on WMI and sometimes WMI breaks for whatever reason. I'm developing a Powershell script that remotely repairs WMI on these broken clients.
Most clients that I attempt to query WMI remotely have no problem while others simply hang my script for minutes and even infinitely. I've gotten past some of these my using the WMISearcher object type and using the ReturnImmediately and Timeout Options properties but there's still a few hanging indefinitely.
I'm looking for something to add to this script so that no client can hang up my script due to a WMI issue.
Here's the small script I have thus far. The script hangs at the "$oResult = $oWmi.Get()" line.
$oWmi = [WMISearcher]'';
$oWmi.Options.ReturnImmediately = $true;
$oWmi.Options.Timeout = '0:0:2';
$oWmi.Scope.Path = "\\$PCNAME\root\cimv2";
$oWmi.Query = 'SELECT * FROM Win32_OperatingSystem';
$oResult = $oWmi.Get();
$oResult | Out-Null
Upvotes: 1
Views: 2256
Reputation: 68331
Have you considered running those queries as background jobs? Then you can just put a timer on the job from your main script, and if it hasn't completed by the time the time expires, you can just remove the job.
Upvotes: 0
Reputation: 43559
Might not be directly related to your problem, but do you know about this: http://support.microsoft.com/kb/932303 ?
Upvotes: 0