Home > SCCM Software Deployment > Refresh all Packages on a SCCM DP

Refresh all Packages on a SCCM DP

I used this successfully in an environment with a primary and multiple secondaries.  Below are the instructions how it works and a few things that you will likely want to change to customize it.
This is to be saved as a HTA file.  There are 3 fields for you to fill in:
  • SCCM Primary Site Code
  • SCCM Primary Server Name
  • SCCM Site Code (to Refresh)

These variables get passed to enable the connection to the primary and ultimatly the DP refresh.  The "SCCM Site Code" is the code for the site you wish to refresh.  For example if your primary is ABC and a secondary is 123 – ABC is the "SCCM Primary Site Code" and 123 would be the "SCCM Site Code".  If 123 has multiple DP’s in the infrastructure design all of them will have their packages refreshed.

  • Replace LOGO.gif with your company’s logo
  • I use an images folder for LOGO.gif and winicon.ico


<Script language="VBScript">
‘ Variables
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
‘ Onload_Window
Sub Onload_Window
 Window.resizeTo 500,275
 window.moveTo (screen.width -900) ,(screen.height -900)
End Sub
‘ Refresh
Sub Refresh
Dim strSiteName , strServerName, strPrimaryCode
strPrimaryCode = PrimaryCode.Value
strSiteCode = SiteCode.Value
strPrimaryServerName = PrimaryServer.Value
Set loc = CreateObject("WbemScripting.SWbemLocator")
Dim WbemServices
Set WbemServices = loc.ConnectServer(strPrimaryServerName, "rootSMSsite_" & strPrimaryCode)
Set DPs = wbemServices.ExecQuery("Select * From SMS_DistributionPoint WHERE SiteCode=’" & strSiteCode & "’")
For Each DP In DPs
   DP.RefreshNow = True
Msgbox "DP packages have been refreshed for " & strSiteCode & "."
End Sub
<title>SCCM DP Refresh</title>
  VERSION="1.0" /> 
<BODY onload=Onload_Window>
<p><td><center><img src="imagesLOGO.gif" hspace=5 vspace=5></center></td></p>
<table style="width: 100%" class="bodyText">
  <td style="width: 300px"><strong>SCCM Primary Site Code:</strong></td>
  <td><span id="PrimaryCodeText"></span>       
    <input name="PrimaryCode" type="text" style="width: 150px"> 
  <td style="width: 300px"><strong>SCCM Primary Server Name:</strong></td>
  <td><span id="PrimaryServerText"></span>       
   <input name="PrimaryServer" type="text" style="width: 150px"> 
  <td style="width: 300px"><strong>SCCM Site Code (to Refresh):</strong></td>
  <td><span id="SiteCodeText"></span>       
   <input name="SiteCode" type="text" style="width: 150px"> 
<td><center><input id=runbutton  type="button" value="Refresh Packages" name="run_button"  onClick="Refresh"></center></td>
  1. Phani
    August 31, 2012 at 1:40 am

    Josh, Thanks for the script. it worked great after changes suggested by Matt.

  2. Nicolas
    March 11, 2011 at 3:10 am

    Hooo really thanks for this script !

  3. Matt Benson
    December 8, 2010 at 12:11 pm

    Thanks Josh.

    This script worked after I tweaked the line Set WbemServices = loc.ConnectServer(strPrimaryServerName, “rootSMSsite_” & strPrimaryCode) and separated the rootSMSsite_ to root/SMS/site_

    I also changed the Onload_Window window.moveTo screen.height to -500. The window was moving to the top of the screen otherwise.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: