By Chandler Gray• Published: • 4 min read

Cannot connect to WMI provider in SQL Server Configuration Manager

mofcomp sqlmgmprovider.mof from an elevated prompt in the SQL Server shared directory fixed this in about ten seconds. Getting there took longer, mostly because the error reads like a permissions problem and it isn’t one.

I logged into a Windows server today to modify the startup parameters when I was met with this error:

SQL Server Configuration Manager WMI provider error

Cannot connect to WMI provider. You do not have permissions or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager Invalid class [0x80041010]

The first line sent me the wrong way. It says you don’t have permission or the server is unreachable, so I checked that I was in the domain admin group and that the services were running, and both were fine. The part that actually matters is Invalid class at the end, which isn’t about permissions at all.

Configuration Manager uses Windows Management Instrumentation to read the status of the SQL Server services. Invalid class means it asked WMI for the SQL Server class and WMI didn’t have one to give it, so the registration is missing rather than blocked. Microsoft’s page on this says it happens because “the WMI provider is removed when you uninstall an instance of SQL Server.” I hadn’t uninstalled anything on this box that I know of, so I don’t know what removed it here, and I didn’t dig once it was working again.

The fix is to recompile the provider with mofcomp. I opened an elevated Command Prompt and changed to the SQL Server shared directory for my version. In my case it was a SQL Server 2022 build, so I used:

cd "C:\Program Files (x86)\Microsoft SQL Server\160\Shared"

Before I ran the command to recompile the provider, I ran this to find the .mof file in the directory:

dir *.mof

The only reason I did that is because the name of the file changes between versions of SQL Server. I’d seen sqlmgmproviderxpsp2up.mof in a different doc and my directory had sqlmgmprovider.mof, which had me wondering for a minute whether I was in the wrong folder. It turns out 2022 is the version where the name changed. Microsoft’s table lists sqlmgmprovider.mof for 2022 at 160, and sqlmgmproviderxpsp2up.mof for everything from 2005 through 2019.

Since SQL Server ships with the .mof file, you should find only one in this directory. If nothing shows up, the file is missing and recompiling won’t help, so you’re left with repairing the SQL Server installation via Control Panel > Programs > SQL Server > Repair.

After identifying the appropriate .mof file, you can finally recompile the provider using the mofcomp command. This is what I ran:

mofcomp sqlmgmprovider.mof

Configuration Manager opened straight after that, so I never restarted anything. Microsoft’s steps do say to restart the WMI service for the change to take effect, and they give this command:

Get-Service winmgmt | Restart-Service -Force

I’m not sure why it worked for me without the restart. It’s possible Configuration Manager re-queries WMI each time it opens and mine picked up the new registration on its own, but I didn’t verify that and I’d still run the restart on a server where the error came back.

The restart takes a few seconds and it doesn’t touch SQL Server, active connections, or running queries. What’s at risk is anything reading through WMI at that moment, and monitoring agents, PowerShell calls and performance counters all do, so on a production box I’d do it in a quiet window rather than in the middle of the day.