Test your Collection WQL queries using WBEMTEST and PowerShell


Hi All,

one of the most useful tips I've learnt on the job is to use WBEMTEST on your Primary Site Server to test your Collection WQL queries. This is useful for doing things like testing the time it takes to run that query. This is especially useful when you get collections that take a very long time to run potentially causing backlogs and delays in collections updating. Using these tools can help you quickly test the queries for timing outside of Configuration Manager.


Log onto your Site Server or from your tools machine you can connect remotely. Ill show you both methods.

Start up WBEMTEST from a command line


Click Connect


In Namespace type in the following


replace XXX with your SiteCode

If your connecting remotely


then click Connect


Click the Query button


Enter your WQL query and click Apply


If you have a valid query you should see a result



You could also run a similar query using PowerShell (Thanks to my fellow PFE’s Ryan Hall and Anthony Watherston for this.)

just replace the value in the $WQL variable quotes with your query and of course PRI with your SiteCode.

$WQL = 'select * from SMS_R_SYSTEM'

$WMI = Get-WmiObject -Namespace Root\SMS\Site_PRI -Query $WQL



and if I want to measure that command for approximate timing

Measure-Command -Expression {Get-WmiObject -Namespace Root\SMS\Site_PRI -Query 'select * from SMS_R_SYSTEM' }