How to use SCCM SDK in C# with a WQL Query that contains joins

Sometimes you just stop and wonder: how DO you make a WQL query with joins and use it with the SCCM SDK in C#? It’s that gnawing thought we all have right?

So after spending an hour reading through people saying: “It’s NOT supported!” and some people who said it was (without any examples whatsoever), I managed to get a small sample working.

So if any of you should come across this challenge (which is of course the most of the world), then here is a code-example on how to do it:

It’s a small console application that output all computers and their last boot time.

Example output:

Last Boot Time: 13-09-2017 10:51:00
Last Boot Time: 26-10-2017 02:34:00
Last Boot Time: 30-10-2017 13:12:00


You can read here on how to connect to the SCCM Server and other SDK code snippets. The SCCM Library I’m using has a connect method described in that article.

Let me know in the comments if you have any questions

Until next time



By | 2017-11-21T14:28:57+00:00 November 21st, 2017|Configuration Manager (SCCM), Scripting & Development|1 Comment

About the Author:

Morten Meisler
Consultant / Developer / Trainer Key areas / products: System Center Service Manager System Center Operations Manager Automation (System Center Orchestrator / Service Management Automation (SMA)) Development: C#.Net, Powershell, SQL, Web development / HTML5 (Javascript,jQuery,CSS,HTML, Wordpress etc.)

One Comment

  1. Harshal December 10, 2017 at 3:58 - Reply

    Great blog. Thanks for the info.
    I not a developer but an SCCM engineer and would like to use SDK. But can’t find good document on how to start for beginner. Some write up would be helpful.


Leave A Comment