Share via


How to Configure Software Updates to Override Maintenance Windows

 

Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager

You configure software updates to override maintenance windows, in System Center 2012 R2 Configuration Manager, by updating the OverrideServiceWindows property of an assignment (deployment).

To configure software updates to override maintenance windows

  1. Set up a connection to the SMS Provider.

  2. Load the specific assignment (deployment) to modify using the SMS_UpdatesAssignment class.

  3. Set the OverrideServiceWindows value to true.

  4. Save the assignment (deployment) and properties.

Example

The following example method shows how to configure software updates to override maintenance windows by using the SMS_UpdatesAssignment class and class properties.

Note

This task only applies to mandatory deployments.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Sub ConfigureSoftwareUpdatestoOverrideMaintenanceWindow(connection, existingAssignmentID)

    ' Get the specific SMS_UpdatesAssignment instance to modify. 
    Set assignmentToModify = connection.Get("SMS_UpdatesAssignment.AssignmentID=" & existingAssignmentID & "")  

    ' Set the new property value.
    assignmentToModify.OverrideServiceWindows = true

    ' Save the assignment.
    assignmentToModify.Put_ 

    ' Output the new property values.
    Wscript.Echo " "
    Wscript.Echo "Set assignment " & existingAssignmentID & " to override service windows."

End Sub
public void ConfigureSoftwareUpdatestoOverrideMaintenanceWindow(WqlConnectionManager connection, int existingAssignmentID)
{
    try
    {
        // Get the specific SMS_UpdatesAssignment instance to change.
        IResultObject updatesAssignmentToChange = connection.GetInstance(@"SMS_UpdatesAssignment.AssignmentID=" + existingAssignmentID);

        // Set OverrideServiceWindows property.
        updatesAssignmentToChange["OverrideServiceWindows"].BooleanValue = true;

        // Save property changes.
        updatesAssignmentToChange.Put();

        // Output success message.
        Console.WriteLine("Set assignment " + existingAssignmentID + " to override service windows.");
    }

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

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

existingAssignmentID

  • Managed: Integer

  • VBScript: Integer

An existing Assignment ID to modify.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

.NET Framework Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also

System Center 2012 R2 Configuration Manager SDK
Configuration Manager Software Updates
Software Updates and Maintenance Windows
SMS_UpdatesAssignment Server WMI Class