While Ago I have posted a solution on how to fix WMI(Windows Management Instrumentation) issues using simple batch script that stops WMI service and recompile all MOF files etc. http://eskonr.com/2009/03/how-to-troubleshoot-the-systems-which-has-wmi-issues-rebuild-wmi-repository/
While working with new windows 7 migration project, we had lot of computers with wmi issue but how to identify which has wmi and fix it automatically. There could be various reasons if configmgr client is not reporting to site server but wmi issue one of major problem .if wmi issue occur, nothing can be performed on configmgr client. No policies, no inventory information nothing will be received or sent to MP.
It would be difficult to identify machines which as WMI corruption so either you can apply wmi script Via GPO to run every time when computer boots up else go with psexec to run the script remotely or different methods which you would prefer.
I come up with simple script that check the functionality of WMI if WMI is working fine, exit the script else repair WMI functionality.
This script you can apply through Logon or make it on schedule basis to run every twice or run once a day through Task Scheduler job on all the machines http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614(v=vs.85).aspx
WMI Isn’t Working! ? http://technet.microsoft.com/en-us/library/ff406382.aspx
Here is out Batch script that check the functionality of wmi using simple wmic command:
wmic computersystem get name
if the the above command gives any output,script exit else repair it.
Here is the complete Batch script :
REM Check if WMI is functioning correctly or not
REM Get computername from WMI
wmic computersystem get name
IF %ERRORLEVEL% EQU 0 goto success
:failure
net stop ccmexec /y
net stop VMAuthdService /y
net stop winmgmt /y
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
net start winmgmt
net start VMAuthdService
net start ccmexec
goto end
:success
goto end
:end
Some theory about WMI and how to check if it is working or not.
What is WMI (windows management Instrumentation)?
Windows Management Instrumentation (WMI) is the infrastructure for management data and operations on Windows-based operating systems
WMI can be used in all Windows-based applications, and is most useful in enterprise applications and administrative scripts
For example, you can:
· Start a process on a remote computer.
· Schedule a process to run at specific times on specific days.
· Reboot a computer remotely.
· Get a list of applications installed on a local or remote computer.
· Query the Windows event logs on a local or remote computer.
How to connect to WMI (local or remote computer):
Type wbemtest from Run command


Click on Connect

The Default Name space is root\cimV2 .You have many namespaces available in WMI.
Click on Connect

Click on Enum Classes

Select Recursive

You can see lot of classes available for cimV2 name space. For more information about available classes in WMI namespace called cimV2 ,please look at here http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx with its description and objects within it.
Now you can see all the classes available within cimV2 name space.
To know more about what each class contains and its objects with in it
Double click on any class which you want to look at it and click on name which you desire

Now we will see how to execute to get required information with in WMI:
Go back to namespace called cimV2 shown below :

Click on Query:

Click on apply to see the results. You can execute any query which has correct syntax to get the correct information.
How do you run wbemtest on remote computer?
1. To connect remotely using tools like CIM Studio or Wbemtest, you must specify a namespace in the form “\\<machinename>\root\<namespace>”
For example: \\mymachine\root\cimv2 as shown below and perform the steps whatever you need as did above.
2. 
How do you check remotely if WMI is working well or not ?
You do it via wbemtest or wmimgmt.msc from run command






See the error above. The RPC server is unavailable means something wrong with the computer could be machine doesn’t not exist on the network or name resolution or permission issue etc
If computer is connect successfully and if you look at properties of the computer ,you will see the below screen,

For more information about WMI Faqs ,please refer this guide http://technet.microsoft.com/en-us/library/ee692772.aspx
Reference Guides on WMI troubleshooting: http://eskonr.com/2009/03/how-to-troubleshoot-the-systems-which-has-wmi-issues-rebuild-wmi-repository/
http://blogs.technet.com/b/configmgrteam/archive/2009/05/08/wmi-troubleshooting-tips.aspx
Reference http://social.technet.microsoft.com/Forums/en-US/configmgradminconsole/thread/a9922b7f-3b81-4b2b-866a-423106b0e9fe
Feel Free to post your comments.