如何配置和部署汇报

通过创建 SMS_UpdatesAssignment Server WMI 类的实例并填充属性,在 Configuration Manager 中创建软件更新部署。

配置和部署更新

  1. 设置与 SMS 提供程序的连接。

  2. 使用 SMS_UpdatesAssignment 类创建新的部署对象。

  3. 填充新的部署属性。

  4. 保存新的部署和属性。

示例

以下示例方法演示如何使用 SMS_UpdatesAssignment 类创建软件更新部署。 请注意,示例方法的参数反映了 的某些 SMS_UpdatesAssignment属性。

重要

以下方法需要分配的配置项数组 (CI_IDs) 。 这些CI_IDs的更新内容必须已下载并添加到更新部署包。

有关调用示例代码的信息,请参阅调用Configuration Manager代码片段


Sub ConfigureAndDeploySUMUpdates(connection,                             _
                                  newApplyToSubTargets,                  _
                                  newArrayAssignedCIs,                   _
                                  newAssignmentAction,                   _
                                  newAssignmentDescription,              _
                                  newAssignmentName,                     _
                                  newDesiredConfigType,                  _
                                  newDPLocality,                         _
                                  newLocaleID,                           _
                                  newLogComplianceToWinEvent,            _
                                  newNotifyUser,                         _
                                  newRaiseMomAlertsOnFailure,            _
                                  newSendDetailedNonComplianceStatus,    _
                                  newStartTime,                          _
                                  newSuppressReboot,                     _
                                  newTargetCollectionID,                 _
                                  newUseGMTTimes)

  ' Create the new deployment object.
  Set newSUMUpdatesAssignment = connection.Get("SMS_UpdatesAssignment").SpawnInstance_

  ' Populate the deployment properties.
  newSUMUpdatesAssignment.ApplyToSubTargets = newApplyToSubTargets
  newSUMUpdatesAssignment.AssignedCIs = newArrayAssignedCIs
  newSUMUpdatesAssignment.AssignmentAction = newAssignmentAction
  newSUMUpdatesAssignment.AssignmentDescription = newAssignmentDescription
  newSUMUpdatesAssignment.AssignmentName = newAssignmentName
  newSUMUpdatesAssignment.DesiredConfigType = newDesiredConfigType
  newSUMUpdatesAssignment.DPLocality = newDPLocality
  newSUMUpdatesAssignment.LocaleID = newLocaleID
  newSUMUpdatesAssignment.LogComplianceToWinEvent = newLogComplianceToWinEvent
  newSUMUpdatesAssignment.NotifyUser = newNotifyUser
  newSUMUpdatesAssignment.RaiseMomAlertsOnFailure = newRaiseMomAlertsOnFailure
  newSUMUpdatesAssignment.SendDetailedNonComplianceStatus = newSendDetailedNonComplianceStatus
  newSUMUpdatesAssignment.StartTime = newStartTime
  newSUMUpdatesAssignment.SuppressReboot = newSuppressReboot
  newSUMUpdatesAssignment.TargetCollectionID = newTargetCollectionID
  newSUMUpdatesAssignment.UseGMTTimes = newUseGMTTimes

  ' Save the new deployment and properties.
  newSUMUpdatesAssignment.Put_

  ' Output the new deployment name.
  Wscript.Echo "Created new deployment " & newSUMUpdatesAssignment.AssignmentName

End Sub


public void ConfigureAndDeploySUMUpdates(WqlConnectionManager connection,
                                        bool newApplyToSubTargets,
                                        int[] newArrayAssignedCIs,
                                        int newAssignmentAction,
                                        string newAssignmentDescription,
                                        string newAssignmentName,
                                        int newDesiredConfigType,
                                        int newDPLocality,
                                        int newLocaleID,
                                        bool newLogComplianceToWinEvent,
                                        bool newNotifyUser,
                                        bool newRaiseMomAlertsOnFailure,
                                        bool newSendDetailedNonComplianceStatus,
                                        string newStartTime,
                                        int newSuppressReboot,
                                        string newTargetCollectionID,
                                        bool newUseGMTTimes)
{
    try
    {

        // Create the deployment object.
        IResultObject newSUMUpdatesAssignment = connection.CreateInstance("SMS_UpdatesAssignment");

        // Populate new deployment properties.
        // Note: newTemplateName must be unique.

        newSUMUpdatesAssignment["ApplyToSubTargets"].BooleanValue = newApplyToSubTargets;
        newSUMUpdatesAssignment["AssignedCIs"].IntegerArrayValue = newArrayAssignedCIs;
        newSUMUpdatesAssignment["AssignmentAction"].IntegerValue = newAssignmentAction;
        newSUMUpdatesAssignment["AssignmentDescription"].StringValue = newAssignmentDescription;
        newSUMUpdatesAssignment["AssignmentName"].StringValue = newAssignmentName;
        newSUMUpdatesAssignment["DesiredConfigType"].IntegerValue = newDesiredConfigType;
        newSUMUpdatesAssignment["DPLocality"].IntegerValue = newDPLocality;
        newSUMUpdatesAssignment["LocaleID"].IntegerValue = newLocaleID;
        newSUMUpdatesAssignment["LogComplianceToWinEvent"].BooleanValue = newLogComplianceToWinEvent;
        newSUMUpdatesAssignment["NotifyUser"].BooleanValue = newNotifyUser;
        newSUMUpdatesAssignment["RaiseMomAlertsOnFailure"].BooleanValue = newRaiseMomAlertsOnFailure;
        newSUMUpdatesAssignment["SendDetailedNonComplianceStatus"].BooleanValue = newSendDetailedNonComplianceStatus;
        newSUMUpdatesAssignment["StartTime"].DateTimeValue = newStartTime;
        newSUMUpdatesAssignment["SuppressReboot"].IntegerValue = newSuppressReboot;
        newSUMUpdatesAssignment["TargetCollectionID"].StringValue = newTargetCollectionID;
        newSUMUpdatesAssignment["UseGMTTimes"].BooleanValue = newUseGMTTimes;

        // Save new deployment and new deployment properties.
        newSUMUpdatesAssignment.Put();

        // Output the new deployment name.
        Console.WriteLine("Created deployment: " + newAssignmentName);
    }

    catch (SmsException ex)
    {
        Console.WriteLine("Failed to create newSUMUpdatesAssignment. Error: " + ex.Message);
        throw;
    }
}

示例方法具有以下参数:

参数 类型 说明
Connection -管理: WqlConnectionManager
- VBScript: SWbemServices
与 SMS 提供程序的有效连接。
newApplyToSubTargets -管理: Boolean
- VBScript: Boolean
确定部署是否应用于子目标。

-真
-假
newArrayAssignedCIs - 托管: Integer 数组
- VBScript: Integer 数组
分配的配置项的数组 (CI_IDs) 。 这些CI_IDs的更新内容必须已下载并添加到更新部署包。
newAssignmentAction -管理: Integer
- VBScript: Integer
新的分配操作。
newAssignmentDescription -管理: String
- VBScript: String
新的分配说明。
newAssignmentName -管理: String
- VBScript: String
新的分配名称。
newDesiredConfigType -管理: Integer
- VBScript: Integer
新的所需配置类型。
newDPLocality -管理: Integer
- VBScript: Integer
新的分发点位置。
newLocaleID -管理: Integer
- VBScript: Integer
新的区域设置 ID。
newLogComplianceToWinEvent -管理: Boolean
- VBScript: Boolean
确定是否将符合性记录到 Windows 事件日志。

-真
-假
newNotifyUser -管理: Boolean
- VBScript: Boolean
标识用户是否收到通知。

-真
-假
newRaiseMomAlertsOnFailure -管理: Boolean
- VBScript: Boolean
标识在失败时是否引发 MOM 警报。

-真
-假
newSendDetailedNonComplianceStatus -管理: Boolean
- VBScript: Boolean
标识是否发送详细的非符合性状态。

-真
-假
newStartTime -管理: String
- VBScript: String
新的开始时间。
newSuppressReboot -管理: Integer
- VBScript: Integer
标识是否取消重新启动。
newTargetCollectionID -管理: String
- VBScript: String
新的目标集合 ID。
newUseGMTTimes -管理: Boolean
- VBScript: Boolean
标识是否使用协调世界时 (UTC) 。

-真
-假

编译代码

此 C# 示例需要:

命名空间

System

System.Collections.Generic

System.Text

Microsoft。ConfigurationManagement.ManagementProvider

Microsoft。ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

可靠编程

有关错误处理的详细信息,请参阅关于Configuration Manager错误

.NET Framework 安全性

有关保护Configuration Manager应用程序的详细信息,请参阅Configuration Manager基于角色的管理

另请参阅

关于软件更新部署

SMS_UpdatesAssignment