Share via


How to Delete Updates from a Deployment Package

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

You remove updates from a software updates deployment package, in Microsoft System Center Configuration Manager 2007, by obtaining an instance of the SMS_SoftwareUpdatesPackage class and using the RemoveContent method.

To delete updates from a software updates deployment package

  1. Set up a connection to the SMS Provider.

  2. Obtain an existing package object by using the SMS_SoftwareUpdatesPackage class.

  3. Remove update content from the existing software updates management package by using the RemoveContent method.

Example

The following example method shows how to remove updates from a software updates deployment package by using the SMS_SoftwareUpdatesPackage class and the RemoveContent method.

Important

No VBScript example was included, as the RemoveContent method does not return from the method call on failure. This is a known issue and is being investigated.

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

Example of the method call in C#:

// Prework for RemoveUpdatesfromSUMDeploymentPackage.
// Define the array of Content IDs to load into the content parameters.
int[] newArrayContentIDs2 = new int[] { 82 };

// Load the update content parameters into an object to pass to the method.
Dictionary<string, object> removeContentParameters = new Dictionary<string, object>();
removeContentParameters.Add("ContentIDs", newArrayContentIDs2);
removeContentParameters.Add("bRefreshDPs", true);

// Call the RemoveUpdatesfromSUMDeploymentPackage method.
SUMSnippets.RemoveUpdatesfromSUMDeploymentPackage(WMIConnection,
                                                  "ABC00001",
                                                  removeContentParameters);
public void RemoveUpdatesfromSUMDeploymentPackage(WqlConnectionManager connection,
                                                  string existingSUMPackageID,
                                                  Dictionary<string, object> removeContentParameters)
{
    try
    {
        // Get the specific SUM Deployment Package to change.
        IResultObject existingSUMDeploymentPackage = connection.GetInstance(@"SMS_SoftwareUpdatesPackage.PackageID='" + existingSUMPackageID + "'");

        // Remove updates from the existing SUM Deployment Package using the RemoveContent method.
        // Note: The method will throw an exception, if the method is not able to add the content.
        IResultObject result = existingSUMDeploymentPackage.ExecuteMethod("RemoveContent", removeContentParameters);

        // Output a success message.
        Console.WriteLine("Removed content from the deployment package. ");
        
    }
    catch (SmsException ex)
    {
        Console.WriteLine("Failed to remove content from the deployment package. Error: " + ex.Message);
        throw;
    }
}

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

A valid connection to the SMS Provider.

existingSUMPackageID

  • Managed: String

The package ID for an existing software updates management package.

removecontentParameters

  • Managed: dictionary object

The set of parameters (ContentIDs, bRefreshDPs) that is passed into the method and used with the RemoveContent method call.

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.

See Also

Concepts

System Center Configuration Manager Software Development Kit
Configuration Manager Software Updates
Software Updates Deployments
How to Assign a Package to a Distribution Point
SMS_SoftwareUpdatesPackage Server WMI Class
RemoveContent Method in Class SMS_SoftwareUpdatesPackage