Detect what version of SQL Server Express engine is available before connection?

You can check the Windows registry for installed versions.

For example, in Powershell you can use this to find all installed versions (note there may be multiple versions installed)

(Get-ChildItem
   -Path "HKLM:SOFTWAREMicrosoftMicrosoft SQL Server Local DBInstalled Versions")
.PSChildName

You would want to check that 12.0 or up was in the results.