fishewa
asked on
WMI Check repair or fix script
I am in desperate need of a script that will check if WMI is working correctly on winXP and Win7 (can be separate scripts) and only repair or fix if needed. I don't want it to run a repair or fix if WMI is working, only if it is broken. I have about 3400 machines out of about 17000 that I think WMI is broken. I plan to run this in a startup script in group policy. I'm not even sure if this is possible, but if it is I will be very grateful for any help.
For a more comprehensive WMI rapair than just rebuilding the repository, you can script the following to run (batch files, PowerShell, VBScript, etc).
net stop winmgmt /y
cd /d %windir%\system32\wbem
if exist %windir%\system32\wbem\repository.bak rmdir /s /q repository.bak
rename %windir%\system32\wbem\repository repository.bak
for %i in (*.dll) do regsvr32 /s %i
for %i in (*.exe) do %i /RegServer
net start winmgmt
After running this you will need to wait a few minutes for the repository to repair itself and then reboot the machine.
And maybe do a recompile of the mof files as well with mofcomp. So:
for %i in (*.mof) do mofcomp %i
ASKER
Thank you for your posts. I have the repair solution as you have posted, but I was hoping that I could find something that would check if WMI was broken and fix it only if it is broken. I don't want to run a fix on every machine if it doesn't need it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
wmic os
if this works then your WMI is at least partially working. You can redirect the output to a text file and make reports.
Nest steps are
**********
net stop winmgmt
cd C:\Windows\System32\Wbem\
ren Repository reposiold
net start winmgmt
**************************
How can you have 17000 broken out of 3400?