Sccm Collection Queries


Queries that can be used for SCCM collections

All Windows 7 Computers

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.Caption like "Microsoft Windows 7%"

Windows 7 x86 Computers

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_PROCESSOR 
on SMS_G_System_PROCESSOR.ResourceID = SMS_R_System.ResourceId inner join 
SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = 
SMS_R_System.ResourceId where SMS_G_System_PROCESSOR.AddressWidth = 
32 and SMS_G_System_OPERATING_SYSTEM.Caption like "Microsoft Windows 7%"

Windows 7 x64 Computers

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_PROCESSOR 
on SMS_G_System_PROCESSOR.ResourceID = SMS_R_System.ResourceId inner join 
SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = 
SMS_R_System.ResourceId where SMS_G_System_PROCESSOR.AddressWidth = 
64 and SMS_G_System_OPERATING_SYSTEM.Caption like "Microsoft Windows 7%"

 All Windows 10 Computers

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.Caption like "Microsoft Windows 10%"

Windows 10 x86 Computers

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_PROCESSOR 
on SMS_G_System_PROCESSOR.ResourceID = SMS_R_System.ResourceId inner join 
SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = 
SMS_R_System.ResourceId where SMS_G_System_PROCESSOR.AddressWidth = 
32 and SMS_G_System_OPERATING_SYSTEM.Caption like "Microsoft Windows 10%"

Windows 10 x64 Computers

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_PROCESSOR 
on SMS_G_System_PROCESSOR.ResourceID = SMS_R_System.ResourceId inner join 
SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = 
SMS_R_System.ResourceId where SMS_G_System_PROCESSOR.AddressWidth = 
64 and SMS_G_System_OPERATING_SYSTEM.Caption like "Microsoft Windows 10%"

Computers in 1 or more AD OUs

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.SystemOUName = "Food.com/Computers/Desktops" or  
SMS_R_System.SystemOUName = "Food.com/Computers/Laptops"

Computers that have not been rebooted in 30 days

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 
DATEDIFF(DD, SMS_G_System_OPERATING_SYSTEM.LastBootUpTime, GETDATE()) > 30

Inactive Clients

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_CH_ClientSummary 
on SMS_G_System_CH_ClientSummary.ResourceId = SMS_R_System.ResourceId where 
SMS_G_System_CH_ClientSummary.ClientActiveStatus = 0

Computers with specific software version

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_ADD_REMOVE_PROGRAMS 
on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId inner join 
SMS_G_System_ADD_REMOVE_PROGRAMS_64 on SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = 
SMS_R_System.ResourceId where (SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName 
like "%SOFTWARENAME%" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "%VERSIONUMBER%") 
or (SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName like "%SOFTWARENAME%" and 
SMS_G_System_ADD_REMOVE_PROGRAMS_64.Version < "%VERSIONUMBER%")

Popular posts from this blog

SCCM Task Sequence GUI - How to set up the TS to work with a GUI

SCCM Applications vs. SCCM Packages: Understanding the Key Differences

How to Deploy a Windows 10 Servicing update as a Application