Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Intune
  • GitHub
  • Windows 11
  • About the author
CCMEXEC.COM – Enterprise Mobility

Tired of adding SCCM Package to distribution points?

Posted on March 12, 2011 by Jörgen Nilsson

Last week I got an idea that it must be possible to add a newly created software distribution package to distribution points automatically. I thought that using a status filter rule to trigger a script which will add the package to distribution points should be no problem. Status filter rules are awesome!

However I ran into some challenges on the way to getting it to work:

  • SMSPXEIMAGES$ should not be added as a distribution point
  • I didn’t want Driver Packages, Software Updates and OS Images to be added automatically
  • And if the package don’t contain source files it should not be added
  • The script has a debug option to write an event in the event-log with the packageID and how many Distributions Points were added.

The script can be downloaded here: https://ccmexec.com/wp-content/uploads/2011/03/addtoDp.txt

It is also posted in the bottom of this page.

These steps describes how to implement the script:

  1. Download the script or copy the text to notepad and save it as “AddtoDP.vbs” in for instance “E:\SCCMTools” or a folder of your choice.
  2. In the SCCM Console create a new status filter rule under Site Management/Site name /Site settings, Status Filter rules
  3. Name it AddtoDP and MessageID “30000”
    AddtopDp3
  4. On the next page, select Run a program and type in “cscript.exe e:\sccmtools\addtodp.vbs %msgdesc” (replace E:\SCCMTools with the path you saved our script in.
    AddtopDp4
  5. Then you are finished. All software packages you create are now automatically added to the standard distirbution points.

Note: As always use this in a test environment at your own risk.

The script:
——————————————————————————————————-

‘This script adds a SCCM package to all standard distribution

const EVENTLOG_INFORMATION = 4

Dim strDPcount
‘Change to 1 if you want the script to create an event-log entry each time a package is created.
sEventlog = “1”

set objShell = CreateObject(“WScript.Shell”)

‘collects command line arguments for the script passed down by the status filter rule
Set args = WScript.Arguments
PackageID = args.Item(7)
strPackageID = Mid(PackageID,2,8)

‘Connect to provider namespace for local computer.
Set objSWbemLocator = CreateObject(“WbemScripting.SWbemLocator”)
Set objSWbemServices= objSWbemLocator.ConnectServer(“.”, “root\sms”)
Set ProviderLoc = objSWbemServices.InstancesOf(“SMS_ProviderLocation”)

For Each Location In ProviderLoc
If Location.ProviderForLocalSite = True Then
Set objSWbemServices = objSWbemLocator.ConnectServer _
(Location.Machine, “root\sms\site_” + Location.SiteCode)
Set Site = objSWbemServices.Get(“SMS_Site='” & Location.SiteCode  & “‘”)
End If
Next

CheckSource
Sub CheckSource
‘ Checks if the package contains sourcefiles and that the packagetype = Software Distribution Package ( value 0)
Set colItems = objSWbemServices.ExecQuery(“Select PkgSourceFlag from SMS_Package where PackageID = ‘” & strPackageID & “‘ and PackageType = ‘0’”)

For Each objItem in colItems
if objitem.pkgsourceflag = “2” then
SetDP
end if
Next

End Sub

Sub SetDp
‘Adds the package to all standard distribution points
Set AllDPs = objSWbemServices.ExecQuery(“Select * From SMS_SystemResourceList WHERE RoleName=’SMS Distribution Point’ and Nalpath not like ‘%PXE%’ “)
strDPcount = “0”
For Each DP In AllDPs
Set newDP = objSWbemServices.Get(“SMS_DistributionPoint”).SpawnInstance_()
newDP.ServerNALPath = DP.NALPath
newDP.PackageID = strPackageID
newDP.SiteCode = Site.SiteCode
newDP.SiteName = Site.SiteName
newDP.Put_
strDPcount = strDPcount + 1
Next

End Sub

‘Write to eventlog if Seventlog = 1
If Seventlog = “1” and strDPcount > “0” then
strMessage = “Added Package: ” & strpackageID & ” to ” & strDPCount & ” Distribution Points”
objShell.LogEvent EVENTLOG_INFORMATION, strMessage
End IF

6 thoughts on “Tired of adding SCCM Package to distribution points?”

  1. Jeroen Erkelens says:
    March 23, 2011 at 3:15 pm

    Hi Jörgen!

    Great article, nicely written and most important; it works like a charm 🙂

    Keep up the good work!

    Reply
  2. Mark Richards says:
    April 7, 2011 at 8:39 pm

    Hi Jörgen,

    Really good article. In testing I discovered an issue, if you have secondary sites that are DPs those DPs are all grouped under the primary site name. As opposed to each respective secondary site name.

    Reply
  3. Jörgen Nilsson says:
    April 11, 2011 at 7:12 am

    Hi,
    Your right! I will update the script so it can be scheduled on the secondary site server aswell adding the packages automaticallywhen they are replicated there.

    Reply
  4. Shweta says:
    May 27, 2011 at 8:30 am

    Jorgen,

    First of all thanks for sharing such a great article. I am also working on a similar issue where
    i need to create a script in such a way that the packages already created are edited to the requirement that they install on XP environment only.

    We can edit the program setting under requirement tab to make it possible, but is there any way to automate it.

    Please suggest.

    Reply
  5. Jörgen Nilsson says:
    June 8, 2011 at 9:24 pm

    Hi,
    Check out this script posted on the Technet Forums, it will do the trick.
    http://social.technet.microsoft.com/Forums/en-US/configmgrsdk/thread/f3b3c095-9dcb-4ddb-84a0-6cebef112cfc

    /Jörgen

    Reply
  6. Pingback: Use ConfigMgr Status Rules to update Distribution Point « Systems Deployment and More…………………………..

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Tweets by ccmexec

Recent Posts

  • Windows Servicing, Personal Teams and Success.cmd
  • Windows MDM Security Baseline – Settings Catalog
  • Configuring MS Edge Security Baseline v107 using Settings Catalog
  • Configuring Desktop App Installer using CSP and script?!
  • Customizing Taskbar and Start in Windows 11 22h2 with PowerShell

©2023 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT