Tag Archives: WMIC

Unable to install SQL Server 2019 – SQL Install Error: The MOF compiler could not connect with the WMI server

The other day I was doing K2 5.5 installation on top of Windows Server 2019 and somehow that install beat all the records in terms of weird issues I run into, and even after re-provisioning server and starting from scratch I had to do resolve quite a few of them. One of those errors (not a directly K2 related one) was inability to install required version of SQL Server. Somehow I got a re-provisioned server with SQL 2014 and, as it is not supported by K2 5.5, I had to install SQL Server 2019 (5.5 supports 2016, 2017, 2019 and Azure SQL Database). But while installing SQL 2019 I run into the following blocking error:

SQL Install Error: The MOF compiler could not connect with the WMI server. This is either because of semantic error such as an incompatibility with existing WMI repository or an actual error such as the failure of WMI server to start.

Error message during installation of SQL Server 2019

Error message is a bit broad and it persisted even after removing all SQL related components from Programs and Features UI as well as deleting some remaining SQL related folders and registry keys. And I was trying to install only database engine services without any extra components and install was keep failing. That required to look into SQL installer logs where it was possible to see more specific/actionable error which looked approximately as follows:

Specified instance {SOME_GUID} via transform :InstID02.mst;:InstName02.mst is already installed. MSINEWINSTANCE requires a new instance that is not installed.

Error message from SQL Server 2019 Install Log

That basically means that some remnants of previous SQL installations are present and block installer from installing new/required versions of some components. And when you already deleted all SQL installer components from Programs and Features UI, you will need to query software list inventory using WMIC (Windows Management Instrumentation command-line) command:

WMIC PRODUCT Where "Caption like '%SQL%'" GET Caption, IdentifyingNumber

That will probably return bunch of SQL components with various GUID, as a minimum you will need to remove components with GUIDs mentioned in SQL installer logs, or if your goal is complete clean up of all SQL components all of them. As those are not visible in Programs and features you may delete them using the following command:

msiexec /x {SOME_GUID}

As in my case I had dozens of components returned and I wanted to do a complete clean up I created a little script for that:

SQL Server Components Clean Up script

With high probability removal of some of the components with the command shown above may fail and it that case you will need to remove them directly from registry looking for GUID value under the following keys:

HKEY_CLASSES_ROOT\Installer\Products\
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products

P.S. There is a blog post on sqlauthority.com which describes dealing with the same issue and helped me to resolve mine.

How to: list disks in Windows CMD

I guess everybody know their way with DIR command to list folder/drives content but what if you need to figure out which drives are available? I recently did a Windows Server 2012 core installation in native VHD boot scenario and it lead me to asking question above when trying to attach my VHDX file from Windows Setup Manager. So I decided to jot down options to list windows drive from CMD below:

1. WMIC option:

wmic logicaldisk get name

or:

wmic logicaldisk get caption

2. fsutil utility:

fsutil fsinfo drives

3. diskpart. This was actually was the only way to list drives I was able to remember from the top of my head – but I didn’t like it as it requires entering into diskpart context and working from there. And it is easy to do something unrecoverable from this context ūüôā

list volume

4. PowerShell:

get-psdrive ‚Äďpsprovider filesystem

I draw most of the options from this article _ which features screenshots and more details on these commands.

Checking for Windows update presence via command line

Just a quick note on how to check if some specific Windows update is installed on the system via command prompt. I thought I already took a note of this, but was not able to find existing post on this. While investigating an issue or doing troubleshooting something more often than not you may need to make sure if some specific update is present in the system or not. And not always you may want to wade through GUI to check this. Let’s say you may want to automate this process or do some mass discovery by running script on multiple machines.

Option 1. Query WMI (Windows Management Instrumentation) namespace.

1-A. Using wmic.exe (powerful, user-friendly CLI to the WMI namespace):

wmic qfe get hotfixid | find "KB99999"

wmic qfe | find "KB99999"

1-B. Using PowerShell:

Get-WmiObject -query 'select * from win32_quickfixengineering' | foreach {$_.hotfixid}

Option 2. Using PS commandlet get-hotfix which was introduced in PS 2.0:

get-hotfix -id KB974332

So this should be enough for most of the cases.