How to Delete Updates from a Deployment Package
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
You remove updates from a software updates deployment package, in System Center 2012 R2 Configuration Manager, by obtaining an instance of the SMS_SoftwareUpdatesPackage class and using the RemoveContent method.
To delete updates from a software updates deployment package
Set up a connection to the SMS Provider.
Obtain an existing package object by using the SMS_SoftwareUpdatesPackage class.
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.
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; } }
Compiling the Code
This C# example requires:
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
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.

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.