During my free time, I do provide assistance to the community. Sometimes via forums, sometimes by giving a free session to local user group related to SQL Server. In this blog, I would share the steps to fox WMI error 0x80041017, Invalid Query.
In one of the forum posts, there was an issue related to WMI query. I asked to use WBEMTest utility to verify if WMI is working correctly on the server. Here were the steps I shared with him.
- From the Start menu, click Run, and then enter WBEMtest.
- The WBEMtest.exe dialog appears. Click Connect.
- In the first text field, type the WMI Provider for Computer Management namespace: root\cimv2. Click Connect.
- Click Query. Type a query that returns the current services running on the local computer:
Select * from Win32_Service.
- Click Apply.
When he performed this test, it gave an error:
Description: Invalid query
This means WMI for Windows is broken. I search and found below script which can help in fixing such error.
Copy below script to notepad and save it as .bat extension. Then, run it from a command prompt with admin right (Run As Administrator)
sc config winmgmt start= disabled
net stop winmgmt /y
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
Reboot the machine and test WMI. Following the outcome of the test
Here is the output of the query after fixing the error
Have you encountered such error? It took me a long time to find the right solution. Hopefully, this would help someone. Please comment if it helped you in fixing any WMI issue.
Reference: Pinal Dave (https://blog.SQLAuthority.com)