Restore WMI

To restore WMI services on a machine which has corrupt WMI or SCCM or wmic will not run.

Option 1
net stop winmgmt
Clear all files from %SystemRoot%\System32\Wbem\Repository
net start winmgmt
winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf
Restart machine
wmic
Please wait while WMIC compiles updated MOF files.


Option 2

net stop winmgmt
c:
cd %systemroot%\system32\wbem
rd /S /Q repository
regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll
mofcomp cimwin32.mof
mofcomp cimwin32.mfl
mofcomp rsop.mof
mofcomp rsop.mfl
for /f %%s in (‘dir /b /s *.dll’) do regsvr32 /s %%s
for /f %%s in (‘dir /b *.mof’) do mofcomp %%s
for /f %%s in (‘dir /b *.mfl’) do mofcomp %%s
restart machine