Error while querying "Win32_Product" WMI class - COMException (0x800706BE)

0

I'm trying to collect all installed SW on each of our servers locally, and I'm using the Win32_Product WMI class for this, but on some of our servers (with Win server 2003 or 2008 R2) I can't query this class.

here is the output from PowerShell:

C:\Users\e****l> Get-WmiObject -Query "SELECT * FROM Win32_Product"
Get-WmiObject :
At line:1 char:14
+ Get-WmiObject <<<<  -Query "SELECT * FROM Win32_Product"
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

I also used this C# code that generated by WMI Code Creator (provided by Microsoft)

        try
        {
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("root\\CIMV2",
                "SELECT * FROM Win32_Product");

            foreach (ManagementObject queryObj in searcher.Get())
            {
                Console.WriteLine("-----------------------------------");
                Console.WriteLine("Win32_Product instance");
                Console.WriteLine("-----------------------------------");
                Console.WriteLine("Name: {0}", queryObj["Name"]);
            }
        }
        catch (ManagementException e)
        {
            MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
        }

and here is the output for this:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x800706BE)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
   at WMISample.MyWMIQuery.Main()

Windows logs shows this event

enter image description here

I'll appreciate any help for that, Thanks

c#
events
powershell
wmi
windows-server-2008
asked on Stack Overflow Apr 2, 2014 by elady • edited Apr 2, 2014 by elady

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0