Recently i was required to move some packages to an 'Archive' folder. Instead of doing this manually, I created this script. The list of packages has to be put into the array in the script:
Option Explicit
'On error resume next
Dim strSMSServer, strSMSSiteCode, strPackageIDs
Dim intSourceFolder, intDestFolder, intObjectType
Dim loc, objSMS
Dim objFolder
Dim arrPackageIDs
Dim retval
strSMSServer = "xxx"
strSMSSiteCode = "xxx"
strPackageIDs = "99900048,9990004B..." 'to move more than one, separate with commas
intSourceFolder = 0 'Source Folder (In Production=8, Root=0)
intDestFolder = 310 'Destination Folder (TobeDeleted = 310)
intObjectType = 2 '2=Package for type of object
Set loc = CreateObject("WbemScripting.SWbemLocator")
Set objSMS = loc.ConnectServer(strSMSServer, "root\SMS\site_" & strSMSSiteCode)
Set objFolder = objSMS.Get("SMS_ObjectContainerItem")
arrPackageIDs = Split(strPackageIDs, ",")
retval = objFolder.MoveMembers(arrPackageIDs, intSourceFolder , intDestFolder , intObjectType)
If Err.Number <> 0 Then
Wscript.Echo Err.Description
End Ifss
Wscript.echo "Done"
-----
to get the folder numbers, use this:
strSiteCode = "xxx"
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"\root\sms\site_" & strSiteCode,UserName,Password)
Dim AdvertisementInfo, objItem
Set AdvertisementInfo = objWMIService.ExecQuery ("select * from SMS_ObjectContainerNode") ' where Name = '" & FolderName & "'")
For Each objItem in AdvertisementInfo
wscript.echo "The folder node ID for """ & objItem.Name & """ is: " & objItem.ContainerNodeID
Next