Serge Chegorian's System Center Blog

Serge Chegorian's System Center Blog

SCCM: How to delete all packages from the DP scheduled for decommissioning

September 4th, 2015

Prior to the decommissioning of the Distribution Point it is recommended to delete all packages assigned to this DP. If you do not do that the ‘orphaned’ packages may sometimes appear on your software distribution reports producing unnecessary noise.

This simple PowerShell one liner removes all packages from the selected DP. Note that this script does not physically remove the package from DP, it simply deletes the relevant record in the database.

Let’s assume CEN is your Central or standalone SCCM site. This is the script:

gwmi -Namespace root\sms\Site_CEN -query "select * from SMS_DistributionPoint where ServerNALPath like '%MYDP001%'" | % ($_.Delete())

Sometimes this script may give you an error. This may happen because CEN is your central site and the package is published on one of the primary sites. To identify package’s source site simply modify the script:

gwmi -Namespace root\sms\Site_CEN -query "select * from SMS_DistributionPoint where ServerNALPath like '%MYDP001%'" | % ($_.SourceSite)

And then change CEN site code in the namespace root\sms\Site_CEN to the site code you have found.

Serge Chegorian's System Center Blog

Serge Chegorian's System Center Blog