You configure software updates to override maintenance windows, in System Center 2012 Configuration Manager, by updating the OverrideServiceWindows property of an assignment (deployment).
To configure software updates to override maintenance windows
-
Set up a connection to the SMS Provider.
-
Load the specific assignment (deployment) to modify using the SMS_UpdatesAssignment class.
-
Set the OverrideServiceWindows value to true.
-
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.
Visual Basic Script | Copy Code |
---|---|
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 |
C# | Copy Code |
---|---|
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 |
|
A valid connection to the SMS Provider. |
existingAssignmentID |
|
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.
Security
For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.