web analytics


How to create a Query Rule

Posted by:

to create a Query Rule

  1. Set up a connection to the SMS Provider.
  2. Verify the Query rule using ValidateQuery from SMS_CollectionRuleQuery WMI Class
  3. Create the Query rule.
  4. Add the Query rule to the collection


Example Output

You can download the code examples from here

About the Author:

Kaido Järvemets is a developer, consultant, trainer specializing in Microsoft System Center Configuration Manager and PowerShell Solutions at Coretech. Kaido frequently speaks at European conferences and had his US debut as speaker at MMS April 2013. Kaido is well-known in the Configuration Manager communities where he’s a key player in the PowerShell game. Kaido host one of the most complete Configuration Manager PowerShell library’s in the world with hundreds of free code samples ready to download and implement – www.cm12sdk.net. Kaido has been awarded Microsoft Most Valuable Professional (MVP) in Microsoft Enterprise Client Management for his work with Configuration Manager from 2011 – to present. Kaido is the founder of System Center User Group Estonia in 2011.


  1. Lindsay Brunetto  March 5, 2013

    I have a question for you. How would I go about making Example #3 able to accept a csv file for the input? I have a few hundred collections I need to put queries on that I’d love to script. Thanks!

  2. Garrett  May 20, 2013

    Same question.

  3. Garrett  May 23, 2013

    I have a PowerShell Script with an input file for query membership rules.
    If you need it please let me know.


Add a Comment