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
Why is there so much iron?
How can an organ that provides biological immortality be unable to regenerate?
Hot air balloons as primitive bombers
How old is Nick Fury?
If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?
Could any one tell what PN is this Chip? Thanks~
How are passwords stolen from companies if they only store hashes?
Why do I have a large white artefact on the rendered image?
Have any astronauts/cosmonauts died in space?
Jem'Hadar, something strange about their life expectancy
Error in master's thesis, I do not know what to do
PTIJ: Which Dr. Seuss books should one obtain?
How to determine the greatest d orbital splitting?
Was World War I a war of liberals against authoritarians?
Why is "la Gestapo" feminine?
How can a new country break out from a developed country without war?
UK Tourist Visa- Enquiry
Imaginary part of expression too difficult to calculate
Why didn’t Eve recognize the little cockroach as a living organism?
Friend wants my recommendation but I don't want to give it to him
Print a physical multiplication table
What is it called when someone votes for an option that's not their first choice?
Gauss brackets with double vertical lines
Hackerrank All Women's Codesprint 2019: Name the Product
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
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
add a comment |
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
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
Mar 7 at 10:31
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
Mar 7 at 15:11
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
Mar 8 at 8:51
add a comment |
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
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
wmi sccm
edited Mar 7 at 15:20
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
Mar 7 at 10:31
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
Mar 7 at 15:11
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
Mar 8 at 8:51
add a comment |
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
Mar 7 at 10:31
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
Mar 7 at 15:11
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
Mar 8 at 8:51
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
Mar 7 at 10:31
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
Mar 7 at 10:31
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
Mar 7 at 15:11
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
Mar 7 at 15:11
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
Mar 8 at 8:51
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
Mar 8 at 8:51
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
Mar 7 at 10:31
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
Mar 7 at 15:11
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
Mar 8 at 8:51