Creating Custom WMI classes for SCCM queries2019 Community Moderator ElectionPowershell Command in C#WQL Query and displaying custom fieldsC# WMI and SCCM2012Executing a WMI method from C++ fails with WBEM_E_INVALID_METHOD_PARAMETERSWMI Invalid Query in C# but works in wbemtest utilityPowershell and SCCM - Unable to make a INNER JOIN query with CIM (__GENERIC CLASS error)Returning multiple properties from different tables in WQL with powershellC# SCCM - Client ActionHow can I update LDAP attributes on the “ds_computer” class through WMI using PowerShellProvider Load Failure in WMI, unable to execute methods

Short scifi story where reproductive organs are converted to produce "materials", pregnant protagonist is "found fit" to be a mother

How do you make a gun that shoots melee weapons and/or swords?

Count each bit-position separately over many 64-bit bitmasks, with AVX but not AVX2

Is there a math expression equivalent to the conditional ternary operator?

Leveling the sagging side of the home

Smooth vector fields on a surface modulo diffeomorphisms

Cycles on the torus

Locked Away- What am I?

The (Easy) Road to Code

Can't make sense of a paragraph from Lovecraft

How can I portion out frozen cookie dough?

Traveling to heavily polluted city, what practical measures can I take to minimize impact?

Too soon for a plot twist?

Can I negotiate a patent idea for a raise, under French law?

Does an unused member variable take up memory?

When an outsider describes family relationships, which point of view are they using?

Can I take the the bonus-action attack from Two-Weapon Fighting without taking the Attack action?

If nine coins are tossed, what is the probability that the number of heads is even?

How to educate team mate to take screenshots for bugs with out unwanted stuff

Would those living in a "perfect society" not understand satire

Do black holes violate the conservation of mass?

What should I do when a paper is published similar to my PhD thesis without citation?

Help! My Character is too much for her story!

Is it appropriate to ask a former professor to order a book for me through an inter-library loan?



Creating Custom WMI classes for SCCM queries



2019 Community Moderator ElectionPowershell Command in C#WQL Query and displaying custom fieldsC# WMI and SCCM2012Executing a WMI method from C++ fails with WBEM_E_INVALID_METHOD_PARAMETERSWMI Invalid Query in C# but works in wbemtest utilityPowershell and SCCM - Unable to make a INNER JOIN query with CIM (__GENERIC CLASS error)Returning multiple properties from different tables in WQL with powershellC# SCCM - Client ActionHow can I update LDAP attributes on the “ds_computer” class through WMI using PowerShellProvider Load Failure in WMI, unable to execute methods










0















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.



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??



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.



MOF File:



#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;
;


SCCM Generated Query:



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


I am testing these commands with the Get-CimInstance command in powershell with the below results



Powershell:



This command returns the joined objects as expected.



Get-CimInstance -Namespace 'rootsmssite_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'


This command throws an "Invalid Query" Error.



Get-CimInstance -Namespace 'rootsmssite_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'









share|improve this question
























  • Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

    – Syberdoor
    2 days ago











  • The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

    – rtranchilla
    2 days ago











  • Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

    – Syberdoor
    yesterday















0















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.



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??



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.



MOF File:



#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;
;


SCCM Generated Query:



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


I am testing these commands with the Get-CimInstance command in powershell with the below results



Powershell:



This command returns the joined objects as expected.



Get-CimInstance -Namespace 'rootsmssite_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'


This command throws an "Invalid Query" Error.



Get-CimInstance -Namespace 'rootsmssite_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'









share|improve this question
























  • Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

    – Syberdoor
    2 days ago











  • The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

    – rtranchilla
    2 days ago











  • Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

    – Syberdoor
    yesterday













0












0








0








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.



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??



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.



MOF File:



#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;
;


SCCM Generated Query:



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


I am testing these commands with the Get-CimInstance command in powershell with the below results



Powershell:



This command returns the joined objects as expected.



Get-CimInstance -Namespace 'rootsmssite_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'


This command throws an "Invalid Query" Error.



Get-CimInstance -Namespace 'rootsmssite_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'









share|improve this question
















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.



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??



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.



MOF File:



#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;
;


SCCM Generated Query:



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


I am testing these commands with the Get-CimInstance command in powershell with the below results



Powershell:



This command returns the joined objects as expected.



Get-CimInstance -Namespace 'rootsmssite_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'


This command throws an "Invalid Query" Error.



Get-CimInstance -Namespace 'rootsmssite_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'






wmi sccm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







rtranchilla

















asked Mar 6 at 23:38









rtranchillartranchilla

228




228












  • Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

    – Syberdoor
    2 days ago











  • The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

    – rtranchilla
    2 days ago











  • Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

    – Syberdoor
    yesterday

















  • Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

    – Syberdoor
    2 days ago











  • The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

    – rtranchilla
    2 days ago











  • Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

    – Syberdoor
    yesterday
















Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

– Syberdoor
2 days ago





Is your problem that the join does not work at all or that the result is one column per table where the information is not displayed anymore but instead something like BaseManagementObjects are listed (also you have a trailing ' in your generated query but I assume this is only a copy and paste artifact)? Also how do you execute the query? Finally I assume it is not possible to do your query in sql on the db directly, because I would allways suggest this method whenever possible (but sometimes it isn't)

– Syberdoor
2 days ago













The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

– rtranchilla
2 days ago





The query does not work at all i receive an "Invalid query" error when i run it. I am executing the query with the below powershell command directly on the management server. Get-CimInstance -Namespace 'rootsmssite_lab' -Query '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'

– rtranchilla
2 days ago













Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

– Syberdoor
yesterday





Ok powershell is good because you will probably get the basemanagement thing once it works and i think powershell can work around that. I have not a lot experience with the mof extensions but I have one custom class in my environment and I can perform an inner join so it should be possible. I created it with the RegKeyToMof tool years ago so I am far from an expert but one thing I noticed is that if I export my mof again is that my custom class seems to derive from "class customclass : SMS_Class_Template" and not g_system like in your example. Maybe this could be a hint?

– Syberdoor
yesterday












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033893%2fcreating-custom-wmi-classes-for-sccm-queries%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55033893%2fcreating-custom-wmi-classes-for-sccm-queries%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived