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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page