SQL Server Troubleshooting: Fixing SMO(Shared Management Objects) and WMI issue

Symptom

You get an error message in your third party applications "smo.dll is missing" when you do a backup from Avamar Client for SQL Database

 

Cause:

This would mostly fail when we are having issues with windows MOF, SQL MoF or WMI Latency

 

Quick Fix:

1. We need to do a wbem test to check the consistency for SQL and windows. If you want to do it for SQL then you can follow the article: https://msdn.microsoft.com/en-us/library/ms179546(v=sql.105).aspx

2. For checking WMI consistency for windows, click start> Run> wbemtest(click ok) > Click connect (Root\CIMV2) > Click query once its connected and run the queries and see if it is fails : Select * from win32_product

  Select * from win32_process

3. Open Cmd and Navigate to C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof and then try to run the command mofcomp sqlmgmproviderxpsp2up.mof to fix the SQL Repository

4. check the consistency with the below command 

 WINMGMT /VERIFYREPOSITORY

5. Run the below command

 WINMGMT /SALVAGEREPOSITORY

 Note: This command will take the content of the inconsistent repository and merge it into the rebuilt repository if it is readable.

6. Fix the windows repository by running the below script > Save this script to notepad and save it as a bat file> Then right click and run as admin:

 @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 

 regsvr32 wmisvc.dll 

 sc config winmgmt start= Auto 

 net start winmgmt 

 “dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %%s in (moflist.txt) do mofcomp %%s”

7. Now, we need to go to regedit to the key > HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Installer and back this registry up. Once this is done, delete the logging entry and reboot the system and try to take backups now.

Note: This is a bug when MSI installer logging is enabled, the win32_product fails. That entry is just to collect MSI Installer logging, it won’t affect anything. 

References:

https://sqlserver-help.com/tag/invalid-class-0x80041010/

Note!! Windows MOF located at

C:\windows\system32\wbem\