SCCM Query for OS Version – Troubleshooting Unexpected Results

sccmwindows 10windows-server-2016

I'm trying to set up some device collections to use for Windows 10 Servicing in SCCM (version 1906). I want to create a collection for each version of Windows 10 (E.g. 1511, 1607, …, 1909). I wasn't sure where to start with the query so I did some searching and found this query on Microsoft TechNet (This example is for build 17134 I.e. 1803):

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_OPERATING_SYSTEM.BuildNumber like "%17134%"

At first it appeared to be working, but then I noticed that the member counts are way out. You can see in this picture that there are 518 devices in the Windows 10 Unknown Version collection which just 'includes' the All Windows 10 collection and 'excludes' all the other collections.

Device Collections

When I look at devices in the Windows 10 Unknown Version they are showing build numbers which should have been included in the queries I have set up. For example the picture below shows a number of devices with build 10.0.17134 which should have been included in the query for my Windows 10 1803 collection (I have checked and they are not included). I'm expecting a figure closer to 500 with 1803 installed.

Windows 10 Unknown Version Collection

I have tried updating the membership of each group but that made no difference. I thought maybe a software inventory may be required, but SCCM clearly knows the build version of the devices so I don't know why some are being returned by the queries but not others.

Any help would be appreciated.

Best Answer

The problem was solved using the following query which I took from the Microsoft scripts provided by Lenniey (https://gallery.technet.microsoft.com/Set-of-Operational-SCCM-19fa8178)

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Build = '10.0.17134'