Sometimes we see WMI errors on the ConfigMgr client that may be related to dll registration on the system or WMI repository situations.
This operating system database is extensively used by ConfigMgr to store system information.
Now we have our own databases (on Compact SQL) for the client to relieve the WMI performance charge that we used to create on WMI, specially with inventory and Updates Management, those are located on C:\WINDOWS\CCM stored on the sdf format for SQL server Compact.
Those databases contents may be only accessed programmatically, or with the out of support component SQL 2005 Management Studio, I plan to have a deeper post on a near future.
But we continue extensively using WMI on the client, so we may need to diagnose the WMI repository status, we can do it following the next post:
https://blogs.technet.microsoft.com/askperf/2014/08/08/wmi-repository-corruption-or-not/
Based on my experience sometimes will be enough to run the command for the repository check (winmgmt /verifyrepository), if the result comes back as inconsistent, your first action is to run “winmmgmt /salvagerepository” followed by running “winmgmt /verifyrepository” again to confirm if it now comes back as consistent.
This simple steps solved most of my issues with WMI on site servers.
If we move to the next step on Windows server 2012 and it still comes back inconsistent, when run “winmgmt /resetrepository” need to be careful as the Cluster namespace will be removed due to the cluswmiuninstall.mof contained in the c:\windows\system32\wbem folder. It has also caused unregistering class names for Cluster Aware Updating (CAU), because of its cauwmiv2.mof also in the wbem folder, so will need to manually recreate this namespaces to have the services back online, this is documented on the previous TechNet post.
We may follow the next actions to solve WMI issues on the machines if the first commands did not solve it, WMI Diag explained:
https://msdn.microsoft.com/en-us/library/aa394603(v=vs.85).aspx
We have deeper information for some specific situations on:
https://technet.microsoft.com/en-us/library/ff406382.aspx
But on some extreme cases we may even need to recreate the WMI namespace completely on the system, on the 2K3 server times was relatively usual the uncontrolled grow on the WMI namespace folder, and the only solution is to recreate the namespace from scratch, this database technology has no shrink options as other databases, so even if we delete information inside the database will see no changes on the space used, and this grow use to have as a result the database corruption.
This should be implemented only on extreme cases as this has a huge impact on the systems.
Possible events that may confirm the WMI repository corruption as sadly there are a bunch of components WMI dependent that may provide different events:
1.Unable to connect to root default or rootcimv2 namespaces. Fails returning error code 0x80041002 pointing to WBEM_E_NOT_FOUND.
2.When we open Computer Management and Right Click on Computer Management (Local) and select Properties, you get the following error: “WMI: Not Found” or it hangs trying connect
3.0×80041010 WBEM_E_INVALID_CLASS
4.Trying to use wbemtest, it hangs
5.Schemas/Objects missing
6.Strange connection/operation errors (0x8007054e):
get-cimclass : Unable to complete the requested operation because of either a catastrophic media failure or a data structure corruption on the disk.
At line:1 char:1
+ get-cimclass -Namespace rootcimv2TerminalServices
During time I modified the original script so can be launched on machines with SQL server installed (the dlls and mof files are not on the default system locations) and exchange server.
The locations of the files may differ on future versions (this is on the Microsoft discrection) so please test largely before run on a production environment.
I hope that this be informative for you
*****************************************************
*****************************************************
@echo off
REM %% for BATCH and% without batch in cmd window
REM ===============================================
sc config winmgmt start= disabled
net stop sms_site_component_manager /y
net stop ccmexec /y
net stop sms_executive /y
net stop sms_server_locator_point /y
net stop sms_reporting_point /y
net stop sms_sql_monitor /y
net stop SMS_SITE_SQL_BACKUP /y
net stop SMS_SITE_VSS_WRITER /y
net stop winmgmt /y
echo.
echo All stopped
echo.
echo All stopped
echo.
ping -n 1 127.0.0.1 > NUL
%systemdrive%
cd “%windir%\system32\wbem”
if exist repository.old2 rmdir /s/q repository.old2
rename repository.old repository.old2
if exist repository.old rmdir /s/q repository.old
rename repository repository.old
md repository
echo.
echo Created new repository folder
echo.
ping -n 1 127.0.0.1 > NUL
echo.
echo register wbem dll’s
echo.
for /f %%s in (‘dir /b *.dll’) do regsvr32.exe /s %%s
wmiprvse /regserver
winmgmt /regserver
echo.
echo register winmgmt and wmiprvse
echo.
ping -n 1 127.0.0.1 > NUL
regsvr32 /s /n /i “%windir%\system32\userenv.dll”
ping -n 1 127.0.0.1 > NUL
regsvr32 /s /n /i “%windir%\system32\scecli.dll”
ping -n 1 127.0.0.1 > NUL
regsvr32 /s /n /i “%windir%\system32\scesrv.dll”
ping -n 1 127.0.0.1 > NUL
echo.
echo Restart winmgmt
echo.
sc config winmgmt start= auto
net start winmgmt
echo.
echo Waiting 30 seconds until winmgmt is full restarted
echo …. then we will use mofcomp for register the mof files
echo.
ping -n 30 127.0.0.1 > NUL
for /f %%s in (‘dir /b *.mof *.mfl’) do mofcomp %%s
cd “%windir%\ccm”
for /f %%s in (‘dir /b *.mof *.mfl’) do mofcomp %%s
on error resume next
echo.
echo check if SQL 2005 mof file exist
echo.
mofcomp “%ProgramFiles%\Microsoft SQL Server\90\Shared\sqlmgmproviderxpsp2up.mof”
echo.
echo check if SQL 2008 mof file exist
echo.
mofcomp “C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof”
rem echo.
rem echo check if Exchange files exist
rem echo.
rem mofcomp exwmi.mof
rem mofcomp -n:root\cimv2\applications\exchange wbemcons.mof
rem mofcomp -n:root\cimv2\applications\exchange smtpcons.mof
rem mofcomp -n:root\cimv2\applications\exchange msgtrk.mof
rem mofcomp exmgmt.mof
net start ccmexec
echo.
echo.
echo ALL done
pause
*****************************************************
*****************************************************