Corrupt WMI Causing SharePoint Search Provisioning to Fail

I worked an issue with a customer yesterday that was causing the SharePoint Search Service to fail to provision the query server role on one of the servers in the farm.  After some research into what SharePoint is trying to do in this call stack, I discovered that in the SearchAdminUtils.GetIPAddress method, we are making a WMI query to get the static IP address for the local server.  Here is the full stack trace:

System.Management.ManagementException: Not found at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at
System.Management.ManagementScope.InitializeGuts(Object o) at
System.Management.ManagementScope.Initialize() at
System.Management.ManagementObjectSearcher.Initialize() at
System.Management.ManagementObjectSearcher.Get() at
Microsoft.Office.Server.Search.Administration.SearchAdminUtils.GetIPAddress(ManagementObjectSearcher ipSearcher, Boolean preferLast) at
Microsoft.Office.Server.Search.Administration.SearchAdminUtils.PreferStaticIPAddress() at Microsoft.Office.Server.Search.Administration.SearchDataAccessServiceInstance.Synchronize(Boolean bCalledFromSSI) at
Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)

To confirm my suspicion that WMI was indeed corrupt, we used the wbemtest.exe utility to check connectivity. 

Click Connect:

image

Click Connect, using the default values:

image

If no error is thrown, you have successfully connected to the local machine via WMI. If you get a “Not Found” error message, you indeed have a corrupted WMI instance.  To further test, you could execute the following WMI query to test the specific class SharePoint is querying during search provisioning, using the following example:

image

If you received an error message when trying to connect, you can attempt to re-register the WMI .dll’s and .exe’s using the following seven steps:

1. Disable and stop the Windows Management Instrumentation service.

2. Right-click Command Prompt and select Run as Administrator.

3. In the Command Prompt, type cd %windir%\system32\wbem and press Enter.

4. Type for /f %s in ('dir /b *.dll') do regsvr32 /s %s and press Enter to re-register WMI DLL files.

5. After completed, type for /f %s in ('dir /b *.mof') do mofcomp %s and press Enter to re-compile WMI mof files.

6. After that, type the command wmiprvse /regserver and press Enter.

7. Start the Windows Management Instrumentation service and change the Startup Type back to Automatic.