Your company's ad could live here and reach over 50,000 people a month!

Share This Post

Community solutions: Removing multiple packages with a script

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.

Joakim’s solution:

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

‘ ————————————————————————————————–
dim fs,objTextFile
set fs=CreateObject("Scripting.FileSystemObject")
dim arrStr
dim x
dim y
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
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
end if
‘Remove Package
Set objPackage = GetObject( "WinMgmts:\\" & strSMSServer & _
"\root\SMS\site_" & strSMSSiteCode & _
":SMS_Package.PackageID=’" & strPackageID & "’")
‘wscript.echo "Deleted " & strPackageID

Original post:

Share This Post

A community professional, keynoter, and evangelist who has driven social media and marketing strategies, editorial successes, delivered customer successes and built some of the largest and longest-running online communities. Rod has created, managed and grown small, medium, and mega-sized conferences; run entire editorial teams to deliver record traffic and market leadership; as product manager, directed the success of hundreds of product releases; supported sales and marketing to ensure customer success; developed, run and sold businesses; written thousands of technical articles, white papers, case studies, and technical documentation; hosted and delivered hundreds of attendance shattering webinars and virtual tradeshows; and delivered keynote speeches and sessions at a wide variety of events including conferences, webinars, events, and user groups.

Leave a Reply