Script to add specific packages to all distribution points

Script to add some packages to all distribution points

As your SCCM hierarchy grows, you might found that you spend more and more time adding packages to new distribution points. In SCCM, for BDP, there is a way to add a package automatically.

This does not happen momentarily, so I wrote this simple script that will add all DPs to the package tagged with the word “$ALLDPS” in the description:


Const Site_Code="HQ2"

Set loc = CreateObject("WbemScripting.SWbemLocator")
Dim WbemServices
Set WbemServices = loc.ConnectServer( , "root\SMS\site_" & Site_Code)

Call AddDPs("SMS_Package")
Call AddDPs("SMS_DriverPackage")
Call AddDPs("SMS_SoftwareUpdatesPackage")
Call AddDPs("SMS_ImagePackage")
Call AddDPs("SMS_BootImagePackage")

Sub AddDPs(PackageClass)

Set AllPackages = wbemServices.ExecQuery("Select * From " & PackageClass & " WHERE Description IS LIKE ""%$ALLDPS%""")
For Each Package in AllPackages
 Set AllDPs = wbemServices.ExecQuery("Select * From SMS_SystemResourceList WHERE RoleName='SMS Distribution Point' AND NALPath IS NOT LIKE ""%SMSPXEIMAGES%""")
 For Each DP In AllDPs
  Set Site = WbemServices.Get("SMS_Site='" & DP.SiteCode & "'")
  Set newDP = WbemServices.Get("SMS_DistributionPoint").SpawnInstance_()
  newDP.ServerNALPath = DP.NALPath
  newDP.PackageID = Package.PackageID
  newDP.SiteCode = DP.SiteCode
  newDP.SiteName = Site.SiteName
End Sub



Just schedule it to run, for instance, every 30 minutes, and don’t forget to add “$ALLDPS” to the description of your package.


Comments (0)

Skip to main content