Close Menu
    Facebook X (Twitter) Instagram
    Sunday, July 20
    X (Twitter) LinkedIn
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»SCCM 2007»How to Fix WMI issues automatically

    How to Fix WMI issues automatically

    Eswar KonetiBy Eswar KonetiJanuary 20, 1:40 pm4 Mins Read SCCM 2007 38,101 Views
    Share
    Facebook Twitter LinkedIn Reddit

    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

    clip_image001

    clip_image002

    Click on Connect

    clip_image003

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

    Click on Connect

    clip_image004

    Click on Enum Classes

    clip_image005

    Select Recursive

    clip_image006

    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

    clip_image007

    Now we will see how to execute to get required information with in WMI:

    Go back to namespace called cimV2 shown below :

    clip_image008

    Click on Query:

    clip_image009

    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. clip_image010

    How do you check remotely if WMI is working well or not ?

    You do it via wbemtest or wmimgmt.msc from run command

    clip_image011

    clip_image012

    clip_image013

    clip_image015

     

    clip_image017

    clip_image018

    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,

    clip_image019

    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.

    Automatic Fix WMI Batch Script Config mgr 2012 configmgr Fix WMI Fixing WMI automatically Microsoft SCCM Repository SCCM SCCM 2007 System center configuration Manager WMI corruption WMI Issue
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    SCCM SQL Report – Compare Installed Apps on TWO Different Computers

    July 13, 10:35 am

    Optimize Your Intune Workflow with a Powerful Browser Extension

    March 22, 10:39 am

    Migrate Microsoft 365 Updates from SCCM/MECM to Intune for Co-Managed Devices

    February 11, 9:50 pm

    24 Comments

    1. Manuel on March 31, 2023 5:13 PM

      Hi, I read your article and tried it. However, I do not really know how to remove it ... Here's the problem:
      2023-03-31 10:16:50,560 FATAL - WMI Operation failure: ServiceDisabled
      WMI.WmiException: ServiceDisabled
      w WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
      w WMI.WmiRoot.InstanceHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
      w winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor)
      w winsw.WrapperService.Main(String[] args)
      WMI.WmiException: ServiceDisabled
      w WMI.WmiRoot.BaseHandler.CheckError(ManagementBaseObject result)
      w WMI.WmiRoot.InstanceHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
      w winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor)
      w winsw.WrapperService.Main(String[] args)

      Its a log from IOBroker...

      Reply
      • Eswar Koneti on April 16, 2023 11:44 AM

        Hi,
        with windows 10 and windows 11, you hardly need to use this wmi fix issue, i have never come across a situation to use run the script on windows 10 or windows 11 OS.
        what is your issue to use this wmi fix?

        Thanks,
        Eswar

        Reply
    2. Praveen Kumar S on October 29, 2018 12:13 PM

      Thank you very much Eswar for this blog, after implementing this it saved our time.
      I have 2 query, please help me in that, im receiving following messages.
      1. The handle is invalid.
      2. Access denied.
      I checked manually able to access print and share but not success on some the machines.

      Reply
      • Eswar Koneti on November 2, 2018 3:30 PM

        Access denied refers to permission issue. You must run as account that has permissions to connect to wmi.

        Thanks,
        Eswar

        Reply
        • Praveen on November 2, 2018 4:51 PM

          And the handle is invalid ?

          Reply
    3. Cassio Santos on April 13, 2017 9:36 AM

      Thank you very much for the information. Very good article! It helped us solve a big problem. Thanks again!

      Reply
      • Eswar Koneti on April 13, 2017 2:27 PM

        Glad it worked for you.

        Thanks,
        ESwar

        Reply
    4. Charles on June 21, 2016 5:53 AM

      Can this be deployed to client's via application or package?? And if so how??

      Reply
      • Eswar Koneti on July 8, 2016 11:37 PM

        Hi Charles,
        if you have WMI issues, client will not be able to download policies from SCCM and you cannot deploy anything due to WMI issue.
        If the client is able to receive the policies etc ,you will have No or less issues on WMI.

        Thanks,
        Eswar

        Reply
        • Charles on July 9, 2016 7:04 AM

          So what method would you suggest using to repair the WMI remotely??

          Reply
          • Eswar Koneti on July 9, 2016 9:00 AM

            You can either use gpo or psexec or other methods http://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/ to remotely run

            Thanks,
            Eswar

            Reply
    5. Tuan on March 24, 2016 5:06 AM

      How to run on it a remote computer?
      psexec.exe file.bat computername
      didn't return any results or know if it ran successfully?

      Reply
      • Eswar Koneti on March 24, 2016 7:29 PM

        you can pipe the results into text file using command >>C:\temp\wmifix_results.txt

        Reply
    6. Craig Pero on September 18, 2013 12:49 AM

      Wont this only let you know when win32_ComputerSystem in the CIMV2 space is bad. It seems you could have corruption in other name spaces and still get successful results back. Or is this the only namespace that really matters to SCCM and thus why you only test that space.
      I guess one could put as many tests before the rebuild which test for failure and if at least 1 fails, then rebuild.

      Reply
      • Eswar Koneti on September 18, 2013 10:49 AM

        If WMI is not working,then it would be issue with name space but not the with class like win32_computersystem.I don't see any scenarios like win32_computersystem class working but other classes(like win32_opearatingsystem) has issues while retrieving information.
        did you see any such scenarios ? CIMV2 is the namespace used to retrieve the Client info to CM database.

        Reply
    7. Pritam on July 10, 2013 1:20 PM

      Amazing Stuff Eswar..!!!! Your script saved my lots of time and logging case with PSS. I was working on repairing WMI for more 24 hours but it was failing. Your script worked like charm and all my issues got resolved.

      Once again Thank You so much for making and providing this script.

      Reply
      • Eswar Koneti on July 11, 2013 12:23 PM

        My Pleasure.

        Reply
    8. Carlo on May 31, 2013 1:44 AM

      I have set the batch to @echo off at the top, and we're seeing the black command prompt box mentioned (by Bhaskar) open on our end (with the name of the computer shown)

      Sending out via PSEXEC isn't working to the systems with problems due to WMI and RPC not functioning properly.

      Reply
      • Eswar Koneti on June 2, 2013 12:16 PM

        yes,if you try to run on local computers,you will get prompt displaying the progress of the script .Over remote computers,i dont see any prompt.,prompt only shows on local machine from where you run but not remote.
        If you have issues connecting to remote computers,you will have to check if you have access to wmi/fix RPC errors.
        for RPC error,i usually check if name resolution is correct or not.Sometimes same IP address is assigned to multiple computers(2).so check that and fix the errors before you try to connect to wmi.

        Reply
    9. Bhaskar on January 29, 2013 4:17 PM

      Tried with echo off still its opening black window for the users.
      Do we have any other way around ?

      Reply
      • Eswar Koneti on January 31, 2013 6:11 AM

        i ran it now on remote computers using psexec.I dont see any command prompt window.

        Reply
    10. Bhaskar on January 25, 2013 5:08 PM

      is there any way we can do it silently without getting black prompt of batch file.
      Probably using Vbscript??

      Reply
      • Eswar Koneti on January 25, 2013 10:03 PM

        try with echo off.

        Reply
    11. Mehmet on January 30, 2012 3:03 AM

      Thanks for the script and detailed information.

      We have encountered lots of corrupted WMI problems on SCCM clients, that's really annoying!

      Reply

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2024 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.