When SMS or SCCM agents fails to install it’s often due to broken or corrupt WMI database. Recreating WMI database is not a good way to solve it since other applications might have stored configuration and values there.
So, I have written together a set of commands which fixes WMI problems in most cases without need of rebuilding whole WMI.
Open an administrative CMD Window and run these commands.
msiexec /unregister
msiexec /regserver
rundll32 wbemupgd, RepairWMISetup
Restart the “Windows Management Instrumentation service”
Change directory to %windir%\System32\WBEM
(\SysWOW64\WBEM on x64)
Then run these FOR loops:
FOR /f %s in ('dir /b /s *.dll') do regsvr32 /s %s
Net stop /y winmgmt
FOR /f %s in ('dir /b *.mof *.mfl') do mofcomp %s
Net start winmgmt
Now, try to install the SMS or SCCM agent again.
If it still fails, reboot and try agent installation once more.