Question

Say I needed a WQL query to find clients running Windows 8 or greater:

WQL query Windows 8 or Greater

SELECT Version FROM Win32_OperatingSystem WHERE Version >= '6.2'

Wouldn't you run the risk of this also including Versions 6.10 (assuming that in the future there will be a 6.10 before a 7.0 version of Windows)? Isn't this just a simple string compare operation?

What is the cleanest way to write this query to get the 'expected' results.

Was it helpful?

Solution 3

A coworker provided me suggestion that I really liked. Instead of trying to query for the unknown, instead filter out the incorrect versions. There really hasn't been a lot of versions of Windows that are not compatible. This would make the query look something like:

SELECT Version FROM Win32_OperatingSystem
WHERE NOT Version like "[12345].%"
  and NOT Version like "6.0.%"
  and NOT Version like "6.1.%"

OTHER TIPS

Split the version number with the decimal point and then filter by both parts in your where clause

if you can check Win32_OperatingSystem then you will find that Version is string data type. so its not possible to apply comparison operator on that. You can select it in a variable do string operation or convert it in float data type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top