Quantcast
Channel: SQL Archives - SQL Authority with Pinal Dave
Viewing all articles
Browse latest Browse all 594

SQL SERVER – WMI Error 0x80041017 – Invalid Query Using WBEMTest

$
0
0

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.

  1. From the Start menu, click Run, and then enter WBEMtest.
  2. The WBEMtest.exe dialog appears. Click Connect.
  3. In the first text field, type the WMI Provider for Computer Management namespace: root\cimv2. Click Connect.
  4. Click Query. Type a query that returns the current services running on the local computer:

Select * from Win32_Service.

  1. Click Apply.

When he performed this test, it gave an error:

Number: 0x80041017
Facility: WMI
Description: Invalid query

This means WMI for Windows is broken. I search and found below script which can help in fixing such error.

WORKAROUND/SOLUTION

Copy below script to notepad and save it as .bat extension. Then, run it from a command prompt with admin right (Run As Administrator)

@echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
wmiprvse /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
cd c:\windows\system32
lodctr /R
cd c:\windows\sysWOW64
lodctr /R

Reboot the machine and test WMI. Following the outcome of the test

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-01

Here is the output of the query after fixing the error

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-02

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)

First appeared on SQL SERVER – WMI Error 0x80041017 – Invalid Query Using WBEMTest


Viewing all articles
Browse latest Browse all 594

Trending Articles