Thursday 28 February 2013

SQL Server Configuration Manager Error: Cannot Connect to WMI Provider



Good day everyone and welcome back again to another instalment of SQL Something (now with pictures!).

Today we are going to look at something that really surprised me during work last week, because frankly I never heard about nor saw anything like it. But, once you tackle an issue with a cool head and your good friend Google, everything will be alright


I stumbled across the issue easily enough. I opened up Management Studio and connected to my production SQL Server Instance when I noticed that the 'ready' icons on both the Instance as well as the SQL Server Agent were white, rather than the usual green:


Disconnecting and reconnecting the instance in Management Studio did not rectify the state. I could, however, still expand the various folders including the DB folders and I could run queries as normal. Data was also being written to the DBs. I also noted that there were no errors in the SQL Logs or the Windows Event Logs. Things seemed fine but something was clearly wrong.

It was when I attempted to open Configuration Manager that I ran into this:




And that’s when things got pretty scary. Configuration Manager could not be accessed. By looking at the wording of the error message I attempted to see if WMI was also inaccessible and surprise! It was. Note, you can check on the status of WMI by going to Start -> Administrator Tools -> Server Manager, expanding the Configuration tab and clicking WMI Control. In the above case you should see a message along the lines of “WMI failed to initialize all required WMI classes”.

I will make a small note here that the last line in the error message displayed by the Config Manager would switch between one of two messages:

  •  "The paging file is too small to for this operation to complete".
  •  A message indicating that there was not enough memory (I will attempt to find the actual wording and will update here accordingly).

The solutions I am going to present is going to be divided into two parts. It is a combination of everything I tried in order to correct my own personal case as well as things I have read.


Part 1 – Preliminary Checks

This first step is one I did not see documented anywhere (and honestly I’m not 100% sure why it worked; if anyone can add to what I’m about to say, please feel free to do so in the comments section). It really was a case of trial and error at its finest.

1.       Firstly, check to see if there are any sessions that are idling for any unreasonable lengths of time (usually a session idles for a few seconds):
  • Go to Start -> Administrator Tools -> Computer Management
  • Expand “Shared Folders”
  • Click on the “Sessions” folder
  • Check the “Idle Time” column for abnormal idle times
  • Close any abnormal sessions.


2.       Check to make sure that no processes are hogging memory unnecessarily:
  • Open Task Manager
  • Check the Processes tab
  • Check memory used by the processes.

In our case my network tech and I saw a session that was idling for about 3 days or so. We closed of that session and checked WMI in Server Manager. Woohoo! It loaded up!


Part 2 – Fixing WMI

…SQL Server Configuration Manager was still busted however, now with a slightly different error:


Note instead of the “The paging file is too small to for this operation to complete” error, there is an “Invalid Class” error. The good news is that this error is fixable by doing one or all of the following:
  1. Verifying the integrity of the WMI Repository folder:
    • Stop the WMI Service:
      • Go to Start -> Administrator Tools -> Services, right click “Windows Management Instrumentation” and select “Stop”.
      • OR open a command prompt and use the following command: “net stop winmgmt”
    • Run the following commands to check integrity:
      • Winmgmt /salvagerepository %windir%\System32\wbem
      • Winmgmt /resetrepository %windir%\System32\wbem
    • Restart the WMI Service:
      • Go to Start -> Administrator Tools -> Services, right click “Windows Management Instrumentation” and select “Start”.
      • OR open a command prompt and use the following command: “net start winmgmt”


  2. Rebuild the WMI Repository folder:
    • Stop the WMI Service
    • Go to C:\Windows\System32\wbem
    • Rename the Repository folder to Repository_Old
    • Restart the WMI Service

  3. Run mofcomp:
    • Run the following in command prompt (as an administrator): mofcomp.exe "C:\Program Files\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof" 
    • Your output should look similar to below:
    • PLEASE NOTE: Depending on the version of your SQL Server instance, the mofcomp command will differ slightly:
      • ...\Microsoft SQL Server\90\... – SQL Server 2005
      • ...\Microsoft SQL Server\100\... – SQL Server 2008 
      • ...\Microsoft SQL Server\110\... – SQL Server 2012
    • ALSO NOTE: Depending on where sqlmgmproviderxpsp2up.mof is located, the command will differ slightly:

      • ...\Program Files\...
      • ...\Program Files (x86)\...

And that my friends, is ‘all’ there is too it. For most people the final step in Part 2 seems to be enough to do the trick, but I tried to include everything I did as well as everything I read. Hope it helps you as it did me.


DISCLAIMER: As stated, I’m not an expert so please, PLEASE feel free to politely correct or comment as you see fit. Your feedback is always welcomed.  :-)

No comments:

Post a Comment