ConfigMgr 2007 Package update confusion (C#)


  • Hi I am trying to update (not refresh) a existing package for ConfigMgr 2007 R3 using C#.

    The package refreshes on the Distribution Point, but does not update. However if I manually update the package the version number does increment.

                    string strQuery = "SELECT * FROM SMS_DistributionPoint WHERE PackageID='" + strPackageID + "'";
                    IResultObject objListOfDistributionPoints = connection.QueryProcessor.ExecuteQuery(strQuery);

                    foreach (IResultObject objDP in objListOfDistributionPoints)
                        MessageBox.Show("Before " + Convert.ToString(objDP["RefreshNow"]));
                        objDP["RefreshNow"].BooleanValue = true;
                        MessageBox.Show("After " + Convert.ToString(objDP["RefreshNow"]));
                catch (SmsException ex)


    Has anybody any ideas what is wrong with the above code. Do I need to supply additional properties?



    Tuesday, April 02, 2013 6:28 PM


All replies

  • Hello JM, 

    I have not heared and made any script yet to update the package version for DP's

    for update the package version, you will have to use manage distribution point, update package version

    Sharad Singh | My blogs: SharadTech | Twitter: @SinghSharaad | | Please mark as helpful/answer if this resolved your issue

    Tuesday, April 02, 2013 6:44 PM
  • You need to use the RefreshPkgSource method of the SMS_Package class as this is a package specific operation, not a DP specific operation:

    Jason |

    • Marked as answer by DMc2014 Monday, April 15, 2013 3:48 PM
    Tuesday, April 02, 2013 7:24 PM
  • Also you can use the following script, 

    I would usually run a batch file to re-compile my SMS Installer script, and then manually update distribution points. You can call this VBScript during your automation process to update the distribution points automatically!

    How to run from the command line:

    So if the SMS Server name is "SMSLAB", site code of "LAB" and the Package ID is "LAB00023", the command line would be:

    cscript UpdateDPs.vbs SMSLAB LAB LAB00023

    How do I determine the Package ID you ask? Here is one of several ways:
  • In the SMS Admin Console, Open System Status, Package Status, and select the desired package.
  • Drill down into a particular distribution point -- the "Path" to the package on the distribution point will be listed as \\%SERVERNAME%\%SMS_DPSHARENAME%\LAB00023 where "LAB00023" is the package ID.

    Watch for word wrap!

    '**Use at your own risk!
    'used wscript.arguments so this can be run from the command line
    'and capture command-line arguments
    Set objArgs = WScript.Arguments
    if objArgs.Count < 3 then
    wscript.echo "proper command usage: "
    wscript.echo vbTAB & "cscript UpdateDPs.vbs SMSSERVERNAME SMSSITECODE SMSPACKAGEID"
    end if

    'Set the variables
    SMS_SERVER = objArgs(0)
    SMS_SITE_CODE = objArgs(1)
    SMS_PACKAGEID = objArgs(2)

    Dim loc, objSMS, objPkgs, objPkg
    Set loc = CreateObject("WbemScripting.SWbemLocator")
    Set objSMS = loc.ConnectServer(SMS_SERVER, "root\SMS\Site_" & SMS_SITE_CODE)
    Set objPkgs = objSMS.ExecQuery("select * from SMS_Package where PackageID = '" & SMS_PACKAGEID & "'")
    for each objPkg in objPkgs

    Set loc = nothing
    Set objSMS = nothing
    Set objPkgs = nothing
    Set objPkg = nothing

  • Sharad Singh | My blogs: SharadTech | Twitter: @SinghSharaad | | Please mark as helpful/answer if this resolved your issue

Wednesday, April 03, 2013 5:18 AM
  • Hi thankyou, managed to find the TechNet on net with examples under OSD.
    Monday, April 15, 2013 2:57 PM