Powershell Get-WmiObject generic-failure

0

I'm struggling with a wmi query (running in Administrator Powershell) that is failing with a generic failure...

Get-WmiObject -Class win32_pnpdevice

results in:

Get-WmiObject : Generic failure At line:1 char:14
+ Get-WmiObject <<<<  -Class win32_pnpdevice
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

This happens on Windows 10 IoT, Windows 10 1809 Enterprise and Windows Embedded S7. For Windows Server 2016 the query is working fine...

I already tried repairing wmi with

net stop winmgmt
winmgmt /salvagerepository %windir%\System32\wbem
winmgmt /resetrepository %windir%\System32\wbem
net start winmgmt

and also renamed the repository folder in C:\Windows\System32\wbem and rebuild the repository. But the query is still not working.

Calling the query via python brings some more error codes:

>>> import wmi
>>> w = wmi.WMI()
>>> pnp = w.Win32_PnPDevice()
Traceback (most recent call last):
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\wmi.py", line 880, in query
    return self._namespace.query(wql, self, fields)
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\wmi.py", line 1072, in query
    return [ _wmi_object(obj, instance_of, fields) for obj in self._raw_query(wql) ]
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\wmi.py", line 1072, in <listcomp>
    return [ _wmi_object(obj, instance_of, fields) for obj in self._raw_query(wql) ]
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\dynamic.py", line 236, in __getitem__
    return self._get_good_object_(self._enum_.__getitem__(index))
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\util.py", line 37, in __getitem__
    return self.__GetIndex(index)
  File "C:\Users\Engineering\AppData\Local\Programs\Python\Python37\lib\site-packages\win32com\client\util.py", line 53, in __GetIndex
    result = self._oleobj_.Next(1)
pywintypes.com_error: (-2147217407, 'OLE error 0x80041001', None, None)

Any ideas?

powershell
wmi
get-wmiobject
asked on Stack Overflow Apr 19, 2021 by Artur

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0