title: Creating Custom WMI classes for SCCM queries
body: <p>I am working to create a custom WMI class for use with SCCM's device collection membership query rules to expose some organization specific information to SCCM for collection creation. I have managed to add a new class in with the MOF file below, and it shows up in the GUI as expected with the desired display name. </p>
  
  <p>The only issue I believe I have left to solve is how to make the generated query work as expected. I know by default joins are not supported in WQL. However Microsoft seems to be using them regularly in these queries, and I have verified they work as expected outside of the application. Is there some sort of joining class I need to create to make this work? Is there some attribute to designate a property as a forigen key??</p>
  
  <p>I have searched through the System Center Configuration Manager SDK documentation, and the WMI reference on the Windows Dev Center site for a few hours without much luck and would really appreciate any helpful input. </p>
  
  <p><strong>MOF File:</strong></p>
  
  <pre><code>#pragma namespace ("\\\\.\\root\\sms\\site_lab")
  [DisplayName("CMDB CI Computer")]
  class SMS_G_System_MTS_cmdb_ci_computer : SMS_G_System    
  {
      [key] uint32 ResourceID;
      string asset_tag;
      string dv_company;
      string dv_cost_center;
      string dv_location;
  };
  </code></pre>
  
  <p><strong>SCCM Generated Query:</strong></p>
  
  <pre><code>select * from  SMS_R_System inner join SMS_G_System_MTS_cmdb_ci_computer on SMS_G_System_MTS_cmdb_ci_computer.ResourceID = SMS_R_System.ResourceId
  </code></pre>
  
  <p>I am testing these commands with the Get-CimInstance command in powershell with the below results</p>
  
  <p><strong>Powershell:</strong></p>
  
  <p>This command returns the joined objects as expected.</p>
  
  <pre><code>Get-CimInstance -Namespace 'root\sms\site_lab' -Query 'select SMS_G_System_PROCESSOR.Architecture from  SMS_R_System inner join SMS_G_System_PROCESSOR on SMS_G_System_PROCESSOR.ResourceId = SMS_R_System.ResourceId'
  </code></pre>
  
  <p>This command throws an "Invalid Query" Error.</p>
  
  <pre><code>Get-CimInstance -Namespace 'root\sms\site_lab' -Query 'select asset_tag from  SMS_R_System inner join SMS_G_System_MTS_cmdb_ci_computer on SMS_G_System_MTS_cmdb_ci_computer.ResourceID = SMS_R_System.ResourceId'
  </code></pre>