How to Configure a Package to Use Binary Delta Replication
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
The following example shows how to configure an existing package to use binary delta replication, in System Center 2012 R2 Configuration Manager, by using the SMS_Package class and the PkgFlags class property.
To configure an existing package to use binary delta replication
Set up a connection to the SMS Provider.
Load the existing package object using SMS_Package class.
Modify the PkgFlags property using the hexadecimal value for AP_USE_BINARY_DELTA_REP.
Save the package and the new package properties.
Example
The following example method configures an existing package to use binary delta replication.
Important |
|---|
The hexadecimal values that define the PkgFlags property are listed in the SMS_Package class reference material. |
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub ModifyPackageToUseBinaryDeltaReplication(connection, existingPackageID)
' Define a constant with the hexadecimal value for AP_USE_BINARY_DELTA_REP.
Const AP_USE_BINARY_DELTA_REP = &H04000000
' Get the specific advertisement instance to modify. Dim packageToModify
Set packageToModify = connection.Get("SMS_Package.PackageID='" & existingPackageID & "'")
' List the existing property values.
Wscript.Echo " "
Wscript.Echo "Values before change: "
Wscript.Echo "--------------------- "
Wscript.Echo "Package Name: " & packageToModify.Name
Wscript.Echo "Package Flags: " & packageToModify.PkgFlags
' Set the new property value.
packageToModify.PkgFlags = packageToModify.PkgFlags OR AP_USE_BINARY_DELTA_REP
' Save the advertisement.
packageToModify.Put_
' Output the new property values.
Wscript.Echo " "
Wscript.Echo "Values after change: "
Wscript.Echo "--------------------- "
Wscript.Echo "Package Name: " & packageToModify.Name
Wscript.Echo "Package Flags: " & packageToModify.PkgFlags
End Sub
public void ModifyPackageToUseBinaryDeltaReplication(WqlConnectionManager connection, string existingPackageID) { // Define a constant with the hexadecimal value for AP_USE_BINARY_DELTA_REP. const Int32 AP_USE_BINARY_DELTA_REP = 0x04000000; try { // Get the specific package instance to modify. IResultObject packageToModify = connection.GetInstance(@"SMS_Package.PackageID='" + existingPackageID + "'"); // List the existing property values. Console.WriteLine(); Console.WriteLine("Values before change:"); Console.WriteLine("_____________________"); Console.WriteLine("Package Name: " + packageToModify["Name"].StringValue); Console.WriteLine("Package Flags: " + packageToModify["PkgFlags"].IntegerValue); // Modify the PkgFlags value to include the AP_USE_BINARY_DELTA_REP value. packageToModify["PkgFlags"].IntegerValue = packageToModify["PkgFlags"].IntegerValue | AP_USE_BINARY_DELTA_REP; // Save the package with the new value. packageToModify.Put(); // Reload the package to verify the change. packageToModify.Get(); // List the existing (modified) property values. Console.WriteLine(); Console.WriteLine("Values after change:"); Console.WriteLine("_____________________"); Console.WriteLine("Package Name: " + packageToModify["Name"].StringValue); Console.WriteLine("Package Flags: " + packageToModify["PkgFlags"].IntegerValue); } catch (SmsException ex) { Console.WriteLine("Failed to modify package. Error: " + ex.Message); throw; } }
Compiling the Code
The C# example requires:
System
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
mscorlib
Robust Programming
For more information about error handling, see About Configuration Manager Errors.

The example method has the following parameters:
Parameter
Type
Description
Connection
swbemServices
Managed: WqlConnectionManager
VBScript: SWbemServices
A valid connection to the SMS Provider.
existingPackageID
Managed: String
VBScript: String
The ID of the existing package.