SCCM Configmgr 2007 Script to delete packages from Assigned DPs

Long ago ,written SCCM report to list packages not used for 6 months as part of Package Archival process .This report tells you to take further action to clean or move to Archive folder to wait for some more months before it goes for Deletion.

What next ? Delete these packages from Assigned DPs to get some disk space ?

You may find several scripts to do this task on the internet but, i  find this is easy for me to get this activity done.

Identify list of package which you want to remove ,pipe them to notepad .You can do more customizations if needed.

Script to delete packages from its assigned Distribution Points.

strComputer =inputBox("Please Enter the SMS provider OR Site where the packages are created" , "SCCM Server name")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set packages=fso.OpenTextFile("C:\PACKAGESTODELETE.txt",1,true)
Set objoutputfile=fso.OpenTextFile("C:\DP_results.txt",2,true)

Do While packages.AtEndOfLine <> True
'read the next line
package = packages.Readline

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\SMS\site_CEN")
if err.number<>0 then
msgbox "server connection failed"
end if
Set colItems = objWMIService.ExecQuery("SELECT * FROM SMS_DistributionPoint where packageid='" & Package & "'")
For Each objItem in colItems
'Wscript.Echo "ServerNALPath: " & objItem.ServerNALPath
objoutputfile.WriteLine ( package & vbTab & " will be deleteting from" & VBTAB & objItem.ServerNALPath)


If Err.number <> 0 Then

objoutputfile.WriteLine ( "Failed to delete" & vbTab & package & "from" &  vbTab & objItem.ServerNALPath)
End If


msgbox "Done"

Note: Please Replace the quotes.

One Response to "SCCM Configmgr 2007 Script to delete packages from Assigned DPs"

Leave a Reply