How to accurately compare software version numbers in device collections?

When specifying the criteria in a device collection based on installed software and version numbers, I check if "Installed Software.Product Version is less than "19.2.50.16", as an example.

But the evaluation of that version number seems to be alphabetical instead of numerical. So version "19.2.6.0" for example would evaluate as false when it should be true. So I have to use dumb work-arounds in some of my version-based collections.

I'm wondering if there is a clearer method to use when performing software version number comparisons in collection queries?

Posted Feb 17, 2022, 3:26 PM UTC

18
GarthMJMSFT Enterprise Mobility MVP•

Product version is NOT a number but a string. As such it will be treated that way within queries. Write your query to find all computers with product and version X then find all computer with product and are NOT version x.

3
BoxofoldcablesOP•

That's one of my work-arounds. But that method doesn't handle future versions or other not yet known versions.

1
GarthMJMSFT Enterprise Mobility MVP•

Collections are for deployment not reporting. For reporting use Sql queries, then there is a trick having sort correctly.

3
BoxofoldcablesOP•

That's what I'm doing, setting up a collection for deploying. Deploying an app to every device that has version X.Y.Z or less of that app installed. Or a version between X.0 and X.Y. Depends on the software.

Now deployment types within an application are able to evaluate file version numbers numerically which is nice. Too bad this functionality doesn't extend to collections.

1
gandraw•

My recommendation is not to try to make such collections because as GarthMJ explained they won't work.

Instead, simply make collections "Computers with Software X", then deploy the newest version of that software to that collections. That way you can then check the monitoring of the deployment to verify that everything is on the newest version.

2
SysAdminDennyBob•

This is what I do. Don't care which old version you have, you are getting this new one. If I really need to know counts of various versions I'm running a query in SQL. Collections are not for reporting. We have all done it but it's a bad habit.

2
denisrennes•

You can deploy a DCM Powershell script testing the installed product version (cast to [version] ) and returning compliant or not compliant. A collection can be built based on the DCM deployment result (right click on the DCM baseline deployment).

It's a bit tedious and a bit slow but it works.

2
slkissinger•

Easy enough... WQL-fu to the rescue. Oops correcting, as a string, it needs to be a like, and you want to "include the ones you want to target"

Where ProductVersion like '19.2.[0-9].%' or ProductVersion like '19.2.[1-4][0-9].%'

Right? maybe? so that would be 19.2.0.x, 19.2.1.x through 19.2.9.x, then also 19.2.10.x, through 19.2.49.x

It's the [ ] that are your friend. So it gets more fun if say, the version you want to be "at least this" is 19.2.55.0 ... but you know you might have 19.2.56.x out there too, and you don't want to stomp on those boxes.

so your like would be... ( '19.2.[0-9].%' OR like 19.2.[1-4][0-9].% OR like '19.2.[5][0-4].%' )

Corrected... I think. But of course, test, test, test. My logic might be flawed still...

I explained it to someone else over here: https://social.technet.microsoft.com/Forums/en-US/69649a2f-71f5-4fd3-a65d-77bd1bcf2e5c/query-for-software-version-lower-than

It can be difficult to try to "solve for every possible future situation" for version numbers, but if you are just looking at "for this round of deployments for this version", it's usually not "too hard" to make up the version less than correctly, using the [ ] stuff. WQL understands that.

2