Friday, June 5, 2015

Powershell:SCCM2012:How to enable Binary Differential Replication or Delta Replication property of a package


Function enableDeltaReplication($SiteServer,$SiteCode,$Namespace,$pkgId)
{
    $USE_BINARY_DELTA_REP = "0x04000000" #Property of SMS_PackageBaseclass for Delta replication. Refer: https://msdn.microsoft.com/en-us/library/cc146062.aspx

    $myPackage = Get-WmiObject -Namespace $Namespace -ComputerName $SiteServer -Query "SELECT *  FROM SMS_PackageBaseclass Where PackageID = '${pkgId}'"
    $res=$myPackage.PkgFlags -bor $USE_BINARY_DELTA_REP
    $myPackage.PkgFlags=$res
    $myPackage.Put()

    $myPackage = Get-WmiObject -Namespace $Namespace -ComputerName $SiteServer -Query "SELECT *  FROM SMS_PackageBaseclass Where PackageID = '${pkgId}'"
    if($myPackage.PkgFlags -band $USE_BINARY_DELTA_REP) {return $true} Else {return $false}
}

# $pkgid = package id of the package to enable binary differential replication

#refer get-cmpackage to obtain package id.



$siteCode="SITE_CODE" #Your CAS site code$replRes=enableDeltaReplication "Your_CAS_ServerName" $siteCode "root\sms\site_$($SiteCode)" $pkgid

Write-Host "Binary replication result ${replRes}"







No comments:

Post a Comment