Windows Insider

The World's Best Configuration Manager Queries: Part II

Readers submit more of their prized queries for everything from checking maintenance windows to deploying software.

Microsoft's System Center Configuration Manager (SCCM) 2007 is such a useful utility for IT environments, it's well worth spending a little more time talking about how to use it to its best advantage. My column last month examined some of the world's finest SCCM queries. This month, we'll serve up some of your submitted favorites.

Joseph Corey submitted two of his favorite queries in SCCM console format. His first helps you by reporting on the last time a client machine was rebooted. Joseph finds this query useful for validating that his maintenance windows are functioning as they should:

select distinct 
SMS_R_System.Name, 
SMS_G_System_OPERATING_SYS
TEM.LastBootUpTime from  
SMS_R_System inner join 
SMS_G_System_OPERATING_SYS
TEM on SMS_G_System_OPERAT 
ING_SYSTEM.ResourceID = 
SMS_R_System.ResourceId

His second query, also in SCCM console format, is handy for populating what he calls "exclusionary collections." He uses this one to create a collection of machines that aren't part of another collection. In this query, replace {collectionID} with the collection ID you're interested in verifying against:

Select SMS_R_SYSTEM.ResourceID, 
SMS_R_SYSTEM.ResourceType, 
SMS_R_SYSTEM.Name,SMS_R_SY
STEM.SMSUniqueIdentifier, 
SMS_R_SYSTEM.ResourceDomain 
ORWorkgroup, SMS_R_SYSTEM.Client from 
SMS_R_System where Client = 1 
and ClientType = 1 and ResourceId 
not in (select ResourceID from 
SMS_CM_RES_COLL_{collectionID})

Steve Oravetz, a network specialist from Wisconsin, submitted a SCCM console-formatted query to retrieve systems on his network that have an installed version of Microsoft Office:

select SMS_R_System.Name, 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName from  
SMS_R_System inner join 
SMS_G_System_ADD_REMOVE_P
ROGRAMS on 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.ResourceID = 
SMS_R_System.ResourceId where 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName like 
"Microsoft Office 2000 Standard" or 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName = 
"Microsoft Office 2000 SR-1 Profes 
sional" or 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName = 
"Microsoft Office 2000 SR-1 Stan 
dard" or 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName = 
"Microsoft Office Professional Plus 
2007" or 
SMS_G_System_ADD_REMOVE_P
ROGRAMS.DisplayName = 
"Microsoft Office Standard 2007"

Last, Eric Schmidt submitted a highly useful query for deploying software. SCCM's ability to create dynamic collections for deploying software is one of its greatest strengths. It helps you push software packages out to computers based on more than just their name or physical location.

However, determining which computers successfully receive and install the software using traditional collections is difficult. Instead, try pushing software to "inverse collections." These collections don't list the software computers have installed, but rather the software they haven't. Here's an example in SCCM console format that collects computers that are missing Microsoft Office 2007:

select SMS_R_SYSTEM.Resour 
ceID, SMS_R_SYSTEM.Resource 
Type, SMS_R_SYSTEM.Name,  
SMS_R_SYSTEM.SMSUniqueIden 
tifier, SMS_R_SYSTEM.Resource 
DomainORWorkgroup, 
SMS_R_SYSTEM.Client from 
SMS_R_System where 
SMS_R_System.Name not in 
(select SMS_R_SYSTEM.Name 
from SMS_R_System inner join 
SMS_G_System_SoftwareFile on 
SMS_G_System_SoftwareFile.Reso
urceId = SMS_R_System.Resour 
ceId where SMS_G_System_Soft 
wareFile.FileName = "winword.exe" 
and SMS_G_System_Software 
File.FileVersion >= "12.0")

Once you've created the list, simply refer any Office 2007 advertisements to this collection until it's empty.

There they are: The world's best SCCM queries. The structure of these queries may not be an exact fit for your IT environment's needs, but they're a good way to learn how others are painting the picture of data in their environments.

About the Author

Greg Shields is a senior partner and principal technologist with Concentrated Technology. He also serves as a contributing editor and columnist for TechNet Magazine and Redmond magazine, and is a highly sought-after and top-ranked speaker for live and recorded events. Greg can be found at numerous IT conferences such as TechEd, MMS and VMworld, among others, and has served as conference chair for 1105 Media’s TechMentor Conference since 2005. Greg has been a multiple recipient of both the Microsoft Most Valuable Professional and VMware vExpert award.

comments powered by Disqus
Upcoming Events

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.