SMS_Application WMI 类在 SCCM 数据库中的等效表 [英] SMS_Application WMI class's equivalent table in SCCM database

查看:33
本文介绍了SMS_Application WMI 类在 SCCM 数据库中的等效表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 System Center Configuration Manager (SCCM) 控制台中有一个 AppModel 应用程序.请参阅以下 SCCM 应用程序属性窗口的屏幕截图:

I'm having an AppModel application in my System Center Configuration Manager(SCCM) console. Please see below screenshot of the properties window of the SCCM application:

我需要知道允许从安装应用程序任务序列安装此应用程序....."复选框的值.它以黄色突出显示.

I need to know the value of 'Allow this application to be installed from the Install Application task sequence.....' checkbox. It is highlighted in yellow.

我尝试使用以下详细信息通过 wbemtest 工具获取它:

I tried to get it through wbemtest tool using below details:

Namespace: root\sms\site_[siteCode] e.g. root\sms\site_lab
Query: select * from SMS_Application

我希望我已经为 AppModel CM 应用程序获得了正确的 Windows 管理规范 (WMI) 类.

I hope I've got the correct Windows Management Instrumentation(WMI) class for AppModel CM applications.

但是wbemtest工具中的输出在结果输出中没有给出任何可以反映checkbox当前状态的字段:

But the output in wbemtest tool doesn't give any field in the result output which can reflect the current condition of checkbox:

Instance of SMS_Application
{
    ApplicabilityCondition = "";
    CategoryInstance_UniqueIDs = {};
    CI_ID = 16777532;
    CI_UniqueID = "ScopeId_6AFF9AA6-E784-4BB8-8DCF-816FCF7A7C09/Application_8e417c4c-da5d-4f1c-91af-ed63d63f9a62/3";
    CIType_ID = 10;
    CIVersion = 3;
    CreatedBy = "NTL\\administrator";
    DateCreated = "20190724122559.000000+000";
    DateLastModified = "20200422051705.000000+000";
    EULAAccepted = 2;
    EULAExists = FALSE;
    ExecutionContext = 0;
    Featured = 0;
    HasContent = TRUE;
    IsBundle = FALSE;
    IsDeployable = TRUE;
    IsDeployed = FALSE;
    IsEnabled = TRUE;
    IsExpired = FALSE;
    IsHidden = FALSE;
    IsLatest = TRUE;
    IsQuarantined = FALSE;
    IsSuperseded = FALSE;
    IsSuperseding = FALSE;
    IsUserDefined = TRUE;
    IsVersionCompatible = TRUE;
    LastModifiedBy = "NTL\\estateadministrator";
    LocalizedCategoryInstanceNames = {};
    LocalizedDescription = "";
    LocalizedDisplayName = "7-Zip 19.00 (x64 edition)";
    LocalizedInformativeURL = "";
    LocalizedPropertyLocaleID = 65535;
    LogonRequirement = 0;
    Manufacturer = "";
    ModelID = 16777500;
    ModelName = "ScopeId_6AFF9AA6-E784-4BB8-8DCF-816FCF7A7C09/Application_8e417c4c-da5d-4f1c-91af-ed63d63f9a62";
    NumberOfDependentDTs = 0;
    NumberOfDependentTS = 0;
    NumberOfDeployments = 0;
    NumberOfDeploymentTypes = 1;
    NumberOfDevicesWithApp = 0;
    NumberOfDevicesWithFailure = 0;
    NumberOfSettings = 0;
    NumberOfUsersWithApp = 0;
    NumberOfUsersWithFailure = 0;
    NumberOfUsersWithRequest = 0;
    NumberOfVirtualEnvironments = 0;
    PermittedUses = 0;
    PlatformCategoryInstance_UniqueIDs = {};
    PlatformType = 1;
    SDMPackageVersion = 3;
    SecuredScopeNames = {"Default"};
    SedoObjectVersion = "9B99BA03-D0FA-417C-8BFF-6095B88AD179";
    SoftwareVersion = "";
    SourceCIVersion = 0;
    SourceModelName = "";
    SourceSite = "LAB";
    SummarizationTime = "20200422125059.533000+***";
};

WMI 类是否可能未公开此 WMI 类支持的数据库的所有列.因此,我正在寻找 SCCM DB 的 SQL DB 表,以便我可以直接在 DB 级别查询它.任何人都可以在这方面帮助我吗?

Is it possible that WMI class is not exposing all the columns of the database backed by this WMI class. Hence, I'm looking for the SQL DB table of SCCM DB so that I can query it directly at DB level. Can anyone help me in this regard?

更新:我还需要可以更新的表来设置/重置与 UI 上显示的复选框对应的布尔字段.

Update: I also need the table which I can update to set/reset the Boolean field corresponding to the checkbox shown on UI.

推荐答案

信息存储在 WMI 中名为 SDMPackageXML 的 XML 元素中.控制台使用的相应表是 fn_listApplicationCIs_List(1031)(它也存在于 fn_listApplicationCIs(1031) 中,我目前不确定这里的确切区别是什么),它被称为 SDMPackageDigest.该元素简称为AutoInstall",仅当设置为 true 时才存在.使用 WQL 查询它是不可能的,但是在脚本中,可以通过在 SMS_Application 对象上不使用查询而是使用 Get()(因为 SDMPackageXML 是一个惰性属性)然后解析 XML 来完成.

The information is stored inside an XML element called SDMPackageXML in WMI. The corresponding table the console uses is fn_listApplicationCIs_List(1031) (it is also present in fn_listApplicationCIs(1031) I am at the moment not sure what the exact difference here is) where it is called SDMPackageDigest. The element is simply called "AutoInstall" and it is only present if set to true. To query it with WQL is impossible, however in a script it could be done by not using a query but a Get() on the SMS_Application Object (because SDMPackageXML is a lazy property) and then parsing the XML.

但是在 SQL 中,可以像这样直接查询列的 XML 部分:

In SQL however it is possible to directly query the XML Part of a column like this:

SELECT 
    DisplayName, 
    CI_UniqueID 
FROM 
    fn_ListApplicationCIs_List(1031) app 
WHERE
    app.isLatest = 1 
AND 
    app.SDMPackageDigest.value('declare namespace p1="http://schemas.microsoft.com/SystemCenterConfigurationManager/2009/AppMgmtDigest";(p1:AppMgmtDigest/p1:Application/p1:AutoInstall)[1]', 'nvarchar(max)') = 'true'

(isLatest 是丢弃旧版本应用程序所必需的).也可以使用该语法在 select 中包含该值,但请记住,对于所有启用 TS 部署的应用程序都是如此,而对于其他应用程序则为 NULL.

(the isLatest is necessary to discard older versions of the application). It is also possible to include the value in the select with that syntax, just keep in mind that it will be true for all Applications that are enabled for TS deployment and NULL for the others.

现在至于如何更新.SCCM 数据库应该永远被写入.我不知道是否有可能以这种方式实现更改(可能是 WMI 总是领先并会覆盖它),而且由于这一切都没有记录,因此可能必须在特定位置进行更改或同时在多个地方.如果必须更新,则必须求助于脚本,该脚本可以与惰性 WMI 属性一起使用.但是我不知道一种不依赖于 SCCM 特定 dll 的方法(并不意味着没有,但我不知道如何很好地使用 XML)所以你需要 Microsoft.ConfigurationManagement.ApplicationManagement.dll从 ConfigMgr 控制台安装目录的 bin 目录.(我编写了代码,以便它可以在安装了控制台的计算机上自动找到它).然后就可以这样了(当然也可以用for包裹):

Now as for how to update. The SCCM DB should never be written to. I don't know if it would even be possible to achieve a change this way (it could be that WMI is always leading and would overwrite it), and as this is all undocumented it could be that changes have to be done at specific places or multiple places at the same time. If this has to be updated you have to resort to scripts, that can work with the lazy WMI properties. However I do not know of a way that is not dependent on SCCM specific dlls (doesn't mean there is none but I do not know how to work with XML well enough for this) so you will need Microsoft.ConfigurationManagement.ApplicationManagement.dll from the bin directory of a ConfigMgr Console Installation dir. (I wrote the code so that it would automatically find it on a computer where the Console is installed). Then you can do it like this (can of course also be wrapped in a for):

[System.Reflection.Assembly]::LoadFrom((Join-Path (Get-Item $env:SMS_ADMIN_UI_PATH).Parent.FullName "Microsoft.ConfigurationManagement.ApplicationManagement.dll"))
$app = gwmi -computer <siteserver> -namespace root\sms\site_<sitecode> -class sms_application -filter "LocalizedDisplayName='<appname>' and isLatest = 'true'"
$app.Get()
$sdmPackageXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($app.SDMPackageXML, $true)
$sdmPackageXML.AutoInstall = $true
$app.SDMPackageXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToString($sdmPackageXML, $true)
$app.Put()

好消息是这种反序列化总是向我们提供 AutoInstall 属性,即使它不存在于 xml 中,因为它是为 sccm 编写的,因此我们可以根据需要将其设置为 true/false.

The nice thing is that this deserialization always presents us with an AutoInstall property even if it is not present in the xml because it was written for sccm so we can just set it true/false as we want.

我们需要 .dll 的原因是序列化.反序列化也可以通过简单的转换为 [xml] 来完成,但我不确定如何再次序列化它.如果可以做到这一点,则不需要外部 dll.(但是 xml 操作不太容易).

The reason we need the .dll is the serialization. Deserialisation can be done with a simple cast to [xml] as well but I am not sure how it could be serialized again. If this can be done there is no need for external dlls. (However the xml manipulation is less easy).

如果您在带有 sccm 控制台的机器上运行此代码,您也可以跳过 wmi 部分并使用 sccm ps commandlet(也包含 SDMPackageXML)中的 Get-CMPllication,但是虽然 dll 可以移动到任何计算机,cmdlet 仅随控制台一起安装,因此我编写了没有它们的示例.

If you run this code on a machine with the sccm console anyway you could also skip the wmi part and use Get-CMApllication from the sccm ps commandlets (contains SDMPackageXML as well) however while the dll can be moved to any computer, the cmdlets are only installed with the console so I wrote the sample without them.

这篇关于SMS_Application WMI 类在 SCCM 数据库中的等效表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆