WQL/SCCM - Comparing version numbers correctly (less than...)

2.4k views Asked by At

I'm having a problem with this part of a SCCM WQL query looking for "less than version 75.0.3770.80":

... where SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770.80"

If i'm not mistaken this is the good old problem seen before in other scenarios (file names for example) where it will return objects with version number :

75.0.3770.142   

Because in it's logic "of course" .142 is "less than" .80 because .1 is less than .8. It doesn't treat it as "142 versus 80" but "1 versus 8"

Is there any way I can work around this? I'm getting a lot of false positives with this query and need to filter them out. If it was straight Powershell I could cast it as [version] but in SCCM, is it at all possible to do this comparison?

3

There are 3 answers

0
Rakha On BEST ANSWER

Ended up using SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770"

1
Ray On

If only the last part of the version number is different, we could use the following one.

... where SMS_G_System_ADD_REMOVE_PROGRAMS.Version like "75.0.3770.[1-7][0-9]"
or ... like "75.0.3770.[0-9]"

Best Regards, Ray

0
Johan Parlevliet On

This goes wrongs if the first version nr reach 100. Better something like this

SMS_G_System_ADD_REMOVE_PROGRAMS.Version like "75.0.%" and
SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770