Query with no result MECM/SCCM collection

matteu31 532 Reputation points
2026-05-19T09:14:53.82+00:00

Hello,

Sorry I don't find the MECM categorie to create this topic.

I'm using systemcenterdudes operationnal query to create some basics collection.

He created 3 to identify W10 supported / support expired soon / support expired. The query seems to not be W10 related so he limit the collection to an other collection with W10 devices only.

It works fine for W10 and I have correct results.

I tried to used the exact same query but limit it to W11 devices only and it doesn't work as expected.

I have different W11 version with some expired, some soon expired but the query doesn't show them on the correct collection.

The query used is this one for expired soon :

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
 LEFT OUTER JOIN SMS_WindowsServicingStates ON SMS_WindowsServicingStates.Build = SMS_R_System.build01 AND SMS_WindowsServicingStates.branch = SMS_R_System.osbranch01 where SMS_WindowsServicingStates.State = '3' 

This one for Expired :

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
 LEFT OUTER JOIN SMS_WindowsServicingStates ON SMS_WindowsServicingStates.Build = SMS_R_System.build01 AND SMS_WindowsServicingStates.branch = SMS_R_System.osbranch01 where SMS_WindowsServicingStates.State = '4'


Is there something wrong here ?

Windows for business | Windows Server | Devices and deployment | System management components
0 comments No comments

2 answers

Sort by: Newest
  1. Jason Nguyen Tran 25,120 Reputation points Independent Advisor
    2026-05-19T10:11:04.1566667+00:00

    Hi matteu31,

    The root of the issue is that the System Center Dudes queries were originally designed around Windows 10 servicing state attributes. Windows 11 uses updated build and branch values, and in some cases the SMS_WindowsServicingStates table does not align exactly with the same fields used for Windows 10. This means that simply reusing the query with a Windows 11 collection limitation may not correctly map the servicing state.

    To troubleshoot, I recommend first verifying that your Windows 11 devices are reporting the correct build and branch values in the SCCM database. You can do this by running a simple query against SMS_R_System to confirm the build01 and osbranch01 fields. If those values are missing or different, the join with SMS_WindowsServicingStates will fail.

    Another approach is to use the built-in “Windows Servicing” collections in MECM, which have been updated to support Windows 11. These collections rely on the proper mapping of servicing states and may save you time compared to custom SQL queries. If you prefer custom queries, you’ll need to adjust the join conditions to reflect the Windows 11 branch values (for example, “co_release” or “22H2” depending on your environment).

    I hope the response provided some helpful insight. If this answer is helpful, please don’t forget to hit “Accept Answer”

    Jason.

    Was this answer helpful?


  2. AI answer

    2026-05-19T09:15:11.9733333+00:00

    The WQL syntax in those queries is valid, but the behavior depends on how the collection is limited and how Windows 11 devices are identified in Configuration Manager.

    Key points to verify:

    1. Collection limiting and OS targeting
      The queries shown return all devices whose SMS_WindowsServicingStates.State is 3 (soon to expire) or 4 (expired). They are not OS-specific. For Windows 10, the collections work because they are limited to a Windows 10–only collection. For Windows 11, the same approach must be used, but with a correctly defined Windows 11–only limiting collection. For example, a query-based collection for a specific OS can be built by joining SMS_R_System with the OS inventory class and filtering on OS properties (such as SKU or version). The documentation shows how to do this for multi-session SKUs:
         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.OperatingSystemSKU = 175
      
      The same pattern should be used to define a Windows 11 devices collection (with the appropriate OS filter), and then the servicing-state collections should be limited to that collection.
    2. Use collection limiting instead of embedding OS logic
      Configuration Manager supports collection-limiting queries in Extended WQL. A query can be limited to a specific collection either by:
      • Setting LimitToCollectionId (for example, when creating a query with New-CMQuery), or
      • Using the console’s Limiting collection field when creating a device collection.
      The servicing-state queries should remain generic (only filter on State = '3' or State = '4') and rely on the limiting collection to scope them to Windows 11 devices.
    3. Confirm the Windows 11 collection is correct
      If the Windows 11 limiting collection is misconfigured (for example, incorrect OS filter, wrong SKU, or missing OS inventory), then the servicing-state collections will not show the expected Windows 11 devices even though the WQL for State = '3' or State = '4' is correct. Validate that:
      • The Windows 11 collection is query-based and correctly filters on Windows 11 OS properties.
      • Devices appear in that Windows 11 collection as expected.
      • The servicing-state collections are limited to that Windows 11 collection.
    4. How to implement via PowerShell (optional)
      If creating or adjusting these collections via PowerShell, use Add-CMDeviceCollectionQueryMembershipRule with the servicing-state WQL and ensure the target collection is already limited to Windows 11 devices:
         $wql = "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 LEFT OUTER JOIN SMS_WindowsServicingStates ON SMS_WindowsServicingStates.Build = SMS_R_System.build01 AND SMS_WindowsServicingStates.branch = SMS_R_System.osbranch01 where SMS_WindowsServicingStates.State = '3'"
         
         Add-CMDeviceCollectionQueryMembershipRule -CollectionName "Win11 Servicing Soon" -QueryExpression $wql -RuleName "Win11 Servicing Soon"
      
      The collection "Win11 Servicing Soon" should itself be limited to the Windows 11 devices collection.

    In summary, the WQL for State = '3' and State = '4' is structurally correct; the issue is likely with how Windows 11 devices are identified and used as the limiting collection. Ensure the Windows 11 collection is correctly defined and used as the limiting collection for the servicing-state collections.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.