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?
I've tried almost everything here and there to fix it, but nothing works from what I've found. The
wbemtest
is returned the same text plus error0x80041001
. Nor WMI service restart or WMI repository reset. Nor numerious MSDN forums.Nor performance counters restore:
https://community.progress.com/s/article/WMI-Based-Active-Monitors-fail-with-error-Generic-Failure-or-Invalid-Query
In the next I've found this:
http://www.nullskull.com/q/81326/remote-wmi--generic-failure-0x80041001.aspx
And tried to run:
The command and output is not related to the issue, but the error in the Event Log got an accidental direction to search:
And found this:
http://forum.oszone.net/post-1276605.html#post1276605
Where the registry key is mentioned:
Then I've tried to start the Print Spooler service and it worked out:
I have no idea how is it connected to the issue.