C#SCCM应用程序:应用程序部署类型要求:[操作系统之一]

时间:2017-05-18 09:02:25

标签: c# deployment types sccm

我正在为我的组织开发一个实用程序/ shell扩展应用程序,它允许同事通过在Windows中右键单击源文件(.MSI,.MST,.EXE& c。)来创建SCCM应用程序和包。资源管理器。

我无法设置

  

设置操作系统要求(例如“一个......& c。”)

在应用程序的部署类型中。

我一直在使用非常有用的sample C# application作为“灵感”,其中包括一种将Global Condition作为要求添加到Deployment Type的方法......但我没有'能够将该代码的元素转换为将操作系统要求添加到DT的内容。

我发现一些Powershell脚本看起来像是在完成这项工作,但我无法成功转置PS示例into C#

我遇到的具体问题是我不知道如何构建(相当复杂的)DesiredConfigurationManagement表达式。

ExpressionBaseGlobalSettingReferenceExpressionRule个对象,我无法弄清楚该怎么做...... SCCM 2012 SDK文档和示例包含没有帮我澄清DesiredConfigurationManagement

那么我的问题就是:

1)我假设我必须使用DesiredConfigurationManagement为部署类型设置操作系统要求。它是否正确?或者是否有更简单的方法来使用WMI查询添加操作系统要求& c?

2)是否有人知道任何可以/可能引导我完成DCM Expression构建的奥秘的Web资源,特别关注C#语法?

提前感谢您的任何帮助。

1 个答案:

答案 0 :(得分:0)

所以也许这就是我在这里提出问题的想法...但我终于设法转移了Powershell的代码!

        CustomCollection<RuleExpression> oOperands = new CustomCollection<RuleExpression>();

        oOperands.Add(new RuleExpression("Windows/All_x64_Windows_7_Client"));

        ExpressionOperator oOperator = ExpressionOperator.OneOf;

        OperatingSystemExpression oOSExpression = new OperatingSystemExpression(oOperator, oOperands);

        Annotation oAnnotation = new Annotation();

        oAnnotation.DisplayName = new LocalizableString("DisplayName", "Operating system One of (All Windows 7 (64-bit))", null);

        NoncomplianceSeverity oNonComplianceSeverity = NoncomplianceSeverity.None;

        Rule nextRule = new Rule("Rule_" + Guid.NewGuid().ToString("B").Replace("{", string.Empty).Replace("}", string.Empty), oNonComplianceSeverity, oAnnotation, oOSExpression);

        thisDT.Requirements.Add(nextRule);

似乎可以胜任这份工作!