WMIC – “os – Alias not found”

windows-server-2008-r2wmi

I have a product which uses WMI to get status of the server it's running on. The application is set to use the following to get the amount of free memory available.

wmic os get freePhysicalMemory

On one specific server in the cluster we get the following error message.

os - Alias not found

Does anyone have any tips on how to fix this missing alias? I've tested the command on other servers in the same cluster (and my computer) and it worked fine. There are other methods to get this information, but the application does not provide an easy way to use them. The server is running Windows Server 2008 R2 SP1.
Thanks!

Best Answer

Your WMI database seems to be broken, you need to follow this guide:

https://msdn.microsoft.com/en-us/library/aa394603(v=vs.85).aspx

to run WMI Diagnosis Utility, which will help you to confirm if that is really your issue and then fix it by following this guide:

First try:

  1. winmgmt /verifyrepository

    If the result is shown as inconsistent, go to step 2

  2. winmgmt /salvagerepository
  3. winmgmt /verifyrepository - to check again wmi repository had been repaired successfully

If it fails - try fully rebuild the WMI Repository follow these steps:

  1. Disable and stop the winmgmt service
  2. Remove or rename C:\Windows\System32\wbem\repository
  3. Enable and start the winmgmt service
  4. Open a CMD prompt as Administrator
  5. In the CMD prompt Navigate to C:\Windows\System32\wbem\
  6. Run the following command:

    for /f %s in ('dir /b *.mof') do mofcomp %s

Note: This will take a minute or so to complete.

  1. Now run the command:

    for /f %s in ('dir /b en-us\*.mfl') do mofcomp en-us\%s

  2. Reboot the server