Joakim was trying to slug through the ConfigMgr 2007 “delete wizard” to remove multiple packages, but because there were so many packages to remove the process was slow, tedious, and almost painful.
Sherry Kissinger recommended example 4-4 from the most excellent and valuable SMS 2003 Recipes book (many of the scripts are still applicable for ConfigMgr 2007) and Joakim’s issue was on the way to resolved.
This is how I solved it.
Using the script from SMS 2003 Recipes and just add code to import from a csv-file I was able to do the removal. The code for the script can be found below.
Thanks Sherry for the tip about the script in book 🙂
‘ Edit the line with strSMSServer with your SCCM server hostname.
‘ Create a csv file with all the packageID:s you wants to remove, seperate them with a semicolon.
‘ Run the Delete_Packages.vbs
‘ Remove the ‘ from " ‘wscript.echo "Deleted " & strPackageID " if you want to display a messagebox
x = 0
y = 0
set objTextFile = fs.OpenTextFile("delete_packages.csv")
Do while NOT objTextFile.AtEndOfStream
arrStr = split(objTextFile.ReadLine,";")
set objTextFile = Nothing
set fs = Nothing
For Each package In arrStr
strSMSServer = "SCCMSERVER"
on error resume next
strPackageID = package
Set objLoc = CreateObject("WbemScripting.SWbemLocator")
Set objSMS= objLoc.ConnectServer(strSMSServer, "root\sms")
Set Results = objSMS.ExecQuery _
("SELECT * From SMS_ProviderLocation WHERE ProviderForLocalSite = true")
For each Loc in Results
If Loc.ProviderForLocalSite = True Then
Set objSMS = objLoc.ConnectServer(Loc.Machine, "root\sms\site_" & _
strSMSSiteCode = Loc.Sitecode
Set objPackage = GetObject( "WinMgmts:\\" & strSMSServer & _
"\root\SMS\site_" & strSMSSiteCode & _
":SMS_Package.PackageID=’" & strPackageID & "’")
‘wscript.echo "Deleted " & strPackageID
Original post: https://myitforum.com/forums/tm.aspx?m=233655