SQL 2016/2017 Relevance Statement

Hello. So I downloaded the CIS checks for SQL 2016 and needed to modify it to account for SQL 2017 as well. I made some changes and came up with what is below but it is highly inefficient. I was wondering if anyone could assist with making the evaluation quicker or is there a cleaner way to do this.

((version of client >= “9.0”)AND(((name of operating system as lowercase starts with “win” and((if x64 of operating system then 2 else 1)= number of values “ProductName” whose(type of it = “REG_SZ”)whose((exist matches(regex("(2012|2012 R2|2016)"))of(it as string)of it))of keys “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion” of(if x64 of operating system then(x32 registry; x64 registry)else x32 registry))))) AND(if(exist key “HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\130\Tools\ClientSetup\CurrentVersion” whose(exists value “CurrentVersion” of it)of registry)then(value “CurrentVersion” of key “HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\130\Tools\ClientSetup\CurrentVersion” of registry as string contains(regex “^13.”))else(if(exist key “HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\130\Tools\ClientSetup\CurrentVersion” whose(exists value “CurrentVersion” of it)of registry)then(value “CurrentVersion” of key “HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\130\Tools\ClientSetup\CurrentVersion” of registry as string contains(regex “^13.”)) else (if(exist key “HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\140\Tools\ClientSetup\CurrentVersion” whose(exists value “CurrentVersion” of it)of registry)then(value “CurrentVersion” of key “HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\140\Tools\ClientSetup\CurrentVersion” of registry as string contains(regex “^14.”)) else(if(exist key “HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\140\Tools\ClientSetup\CurrentVersion” whose(exists value “CurrentVersion” of it)of registry)then(value “CurrentVersion” of key “HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\140\Tools\ClientSetup\CurrentVersion” of registry as string contains(regex “^14.”)) else(false)))) AND(exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine” whose(value “PowerShellVersion” of it > “1.0”)of registry)))| false