master document of queries for SCCM collections
Home  » master document of queries for SCCM collections

master document of queries for SCCM collections
Posted: Thu, Dec 17, 2009 10:32 AM :: Rank: 56
Author
Points: 7501
Level: System Center Specialist

I see many sites and blogs with queries to be used in SCCM collections. I cannot locate a single document with a large list of queries. Is there anyone with a list of such queries willing to share for my use?

If yes, would you please add a copy in your response to my query?

   Report Abuse
Re: master document of queries for SCCM collections
Posted: Fri, Dec 18, 2009 2:35 PM :: Rank: 54
Author
Points: 40804
Level: System Center Expert
Hey this is a cool one, even if you don't have a big list send them into us here at SCC and we will complie them in to a useful doc.
   Report Abuse
RE: master document of queries for SCCM collections
Posted: Fri, Dec 18, 2009 3:54 PM :: Rank: 86
Author
Points: 42748
Level: System Center Expert

 I will contribute some of the collection queries I have to  this. Should I blog them or post them right here?

   Report Abuse
Re: master document of queries for SCCM collections
Posted: Fri, Dec 18, 2009 4:41 PM :: Rank: 68
Author
Points: 91
Level: System Center Enthusiast
Or you could send them to simon at skinner.fr and Pete and I will put it together
   Report Abuse
RE: master document of queries for SCCM collections
Posted: Thu, Dec 24, 2009 8:01 PM :: Rank: 63
Author
Points: 42748
Level: System Center Expert
   Report Abuse
RE: master document of queries for SCCM collections
Posted: Thu, Dec 24, 2009 8:12 PM :: Rank: 62
Author
Points: 42748
Level: System Center Expert

This collection query one shows how to query for free disk space to determine readiness for MS Office and other software installations. Collection Query - Office 2003 Pro Installation

 

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Thu, Dec 24, 2009 8:14 PM :: Rank: 59
Author
Points: 42748
Level: System Center Expert
   Report Abuse
RE: master document of queries for SCCM collections
Posted: Thu, Dec 24, 2009 8:59 PM :: Rank: 54
Author
Points: 65622
Level: System Center Expert

Good start Tommy, here's one before I get back to Christmas Dinner and family time. This collection query will show you all systems that have a particular service installed based on service NAME ..not the Display Name...(NAME is what you'd use in a 'net start' or 'net stop' command)

this one would show you all servers with the OpsMgr SDK service installed (all Management Server basically)

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.ResourceId in (select SMS_R_System.ResourceId from SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.Name = "OMSDK")

 And technically, if  you throw a not in there, you could see all systems without the service

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.ResourceId not in (select SMS_R_System.ResourceId from SMS_R_System inner join SMS_G_System_SERVICE on SMS_G_System_SERVICE.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SERVICE.Name = "OMSDK")

 

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Thu, Dec 24, 2009 9:29 PM :: Rank: 69
Author
Points: 42748
Level: System Center Expert

 Okay, one more before I knock off...A collection query to find systems with an application installed based on the contents of Add/Remove Programs.

Here's a collection query I use to find SQL Server 2005 components installed based on display names. I think that Windows service query you just posted would be more accurate in some cases.

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.ResourceId in (select distinct SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID   from SMS_G_System_ADD_REMOVE_PROGRAMS   where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = 'Microsoft SQL Server 2005') 

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Sat, Dec 26, 2009 9:22 PM :: Rank: 146
Author
Points: 42748
Level: System Center Expert

 And suppose worth mentioning an example of a collection query that shows clients client that do not have an application installed. You basically just add the NOT into the query.

Here's a query to show systems without Office 2007 Professional installed. 

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.ResourceId NOT in (select distinct SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID   from SMS_G_System_ADD_REMOVE_PROGRAMS   where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = 'Microsoft Office Professional 2007')

Again the key is to make sure the value in DisplayName at the end of the query matches what you see in Add/Remove Programs

I'll post a couple of more complex examples soon.

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Sun, Dec 27, 2009 12:20 AM :: Rank: 91
Author
Points: 42748
Level: System Center Expert

 Here's the collection query for Windows 2008 Server systems:

select SMS_R_System.Name, SMS_R_System.SMSAssignedSites, SMS_R_System.IPAddresses, SMS_R_System.IPSubnets, SMS_R_System.OperatingSystemNameandVersion, SMS_R_System.ResourceDomainOrWorkgroup, SMS_R_System.LastLogonUserDomain, SMS_R_System.LastLogonUserName, SMS_R_System.SMSUniqueIdentifier, SMS_R_System.ResourceId, SMS_R_System.NetbiosName from SMS_R_System where SMS_R_System.OperatingSystemNameandVersion like "%Server 6.0%"

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Mon, Dec 28, 2009 8:45 AM :: Rank: 48
Author
Points: 42748
Level: System Center Expert

 Here's a brief how-to to create a ConfigMgr collection based on the memberships of multiple existing collections. I have used this a few times and think it's pretty cool! 

http://sms-hints-tricks.blogspot.com/2008/11/collection-query-of-multiple.html

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Mon, Dec 28, 2009 10:07 AM :: Rank: 75
Author
Points: 11589
Level: System Center Expert

Hey guys, here is a tutorial I have used more than once. How to create a collection query based on Active Directory group membership. 

http://www.jannesalink.com/blog1.php/2008/10/16/deploy-sccm-packages-based-on-active-dir

 

Thanks!

   Report Abuse
Re: master document of queries for SCCM collections
Posted: Mon, Dec 28, 2009 5:51 PM :: Rank: 79
Author
Points: 1797
Level: System Center Specialist
Lots of queries in the Code Repository. Plus, you can create your own code packs and share them with the community.



http://www.myitforum.com/articles/11/view.asp?id=8535
   Report Abuse
RE: master document of queries for SCCM collections
Posted: Mon, Dec 28, 2009 6:38 PM :: Rank: 59
Author
Points: 42748
Level: System Center Expert

 That's an interesting idea. Perhaps I will create a code pack of my queries, reports and scripts and post them here on SCC.

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Mon, Dec 28, 2009 11:42 PM :: Rank: 109
Author
Points: 42748
Level: System Center Expert

Here's another I've been playing with. ConfigMgr collection query with variables. Here's a collection query that 

SELECT * FROM SMS_R_System
WHERE SystemOUName like "%PLAY%"

This will match all systems that have an OU that has the word PLAY in it

http://social.technet.microsoft.com/Forums/en/configmgrsdk/thread/6554f9a4-6973-4463-8ee4-37836424c519

   Report Abuse
RE: master document of queries for SCCM collections
Posted: Wed, Dec 30, 2009 10:56 PM :: Rank: 36
Author
Points: 42748
Level: System Center Expert

 Here's a useful collection query I used just today....got this one from Cameron

ConfigMgr Systems without Current Service Packs, and System Patch Status

 
 
 
 

   Report Abuse

Home  » master document of queries for SCCM collections
Top Contributors
Featured Members
Pete Zerger
Points: 65622
Level: System Center Expert
Tommy Gunn
Points: 42748
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27734
Level: System Center Expert