Corrigindo Erro de WMI Invalid NameSpace

winmgmt /verifyrepository

Actions to try

First try the following actions to see if they resolve your issue:

a. Re-register all of the dlls and recompile the .mofs in the wbem folder and re-registering WMI Service and Provider. You can use the following script by saving to txt file then renaming to .bat and running from command prompt with admin right and changing focus to following directory: C:\Windows\System32\Wbem.

@echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
wmiprvse /regserver
winmgmt /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s

b. Reboot the machine and test WMI

Next, check the repository for consistencies:

For Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2, you can run winmgmt /verifyrepository from a command prompt.
For Older OS like Windows XP and Windows Server 2003 run: WmiDiag tool with the checkconsistency option. For example: WmiDiag checkconsistency

If repository is found to be inconsistent:

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

cd c:\windows\SysWOW64\WBEM

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

goto end
:success
goto end
:end

===============================

a. For Vista and newer, run from elevated command prompt:

Winmgmt /salvagerepository

Note this command will take the content of the inconsistent repository and merge it into the rebuilt repository if it is readable

If the above doesn’t work, then run:

Winmgmt /resetrepository

Note this will reset repository to the initial state when the OS was first installed

For Windows XP and Windows Server 2003, there are no built in switches to rebuild the Repository, so you must do it manually.

Warning: Rebuilding the WMI repository has resulted in some 3rd party products not working until their setup is re-run & their MOF re-added back to the repository.

If /salvagerepository or /resetrepository does not resolve the issue, then manually rebuild repository:

Change startup type to Window Management Instrumentation (WMI) Service to disabled
Stop the WMI Service; you may need to stop IP Helper Service first or other dependent services before it allows you to stop WMI Service
Rename the repository folder:  C:\WINDOWS\system32\wbem\Repository to Repository.old
Open a CMD Prompt with elevated privileges
CD windows\system32\wbem
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
Set the WMI Service type back to Automatic and start WMI Service
cd /d c:\  ((go to the root of the c drive, this is important))
for /f %%s in ('dir /s /b *.mof *.mfl') do mofcomp %%s
Reboot the server

Finally, install latest hotfixes for WMI as they can help prevent issue from recurring. If you continue to have recurring WMI repository corruption issues on same machine, please engage a Microsoft Support Engineer for further troubleshooting and assistance.

=====================================================

Additionally, your computer must have the Terminal Service role and the Windows System Resource Manager feature installed.
Restart requirement
You must restart the computer after you apply this hotfix.
Registry information
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows

You can use the following registry entry to change the interval between the WMI polling queries that are used by the Accounting feature:

Location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WSRM\Parameters
Name: PollingInterval
Type: REG_DWORD
Value: Polling query interval in seconds

The
PollingInterval
registry entry specifies the interval in seconds. The default value is 30 (30 seconds).

After you install this hotfix, you can use the following registry entry to change the interval between the WMI polling queries:

Location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WSRM\Parameters
Name: ClusterSvcStatusPollInterval
Type: REG_DWORD
Value: Polling query interval in seconds

The
ClusterSvcStatusPollInterval
registry entry specifies the interval in seconds. The default value is 300 (5 minutes).
File information
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
For all supported x86-based versions of Windows Server 2008

Fontes:

http://www.ittrainingday.com/2013/01/rebuilding-wmi-windows-management.html

http://blogs.technet.com/b/configmgrteam/archive/2009/05/08/wmi-troubleshooting-tips.aspx

http://msdn.microsoft.com/en-us/library/aa394603(VS.85).aspxhttp://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/

http://eskonr.com/2009/03/how-to-troubleshoot-the-systems-which-has-wmi-issues-rebuild-wmi-repository/