Close Menu
    Facebook X (Twitter) Instagram
    Sunday, October 12
    X (Twitter) LinkedIn Reddit RSS
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»ConfigMgr (SCCM)»SCCM Configmgr 2007 Script move packages to Archive Folder

    SCCM Configmgr 2007 Script move packages to Archive Folder

    Eswar KonetiBy Eswar KonetiMarch 13, 1:40 pm3 Mins Read ConfigMgr (SCCM) 1,014 Views
    Share
    Facebook Twitter LinkedIn Reddit

    This is Continuation to previous post package archival process.up on the query results,I would not delete the packages from console directly rather i delete them from its assigned Distribution points and move them to Archive folder and let be there for sometime until for sometime incase if it is required.

    If you have large number of packages,you may find difficult in moving the packages by identifying where they reside (if you have subfolders).If you have less packages <10,you may use the report to know the root path of the package  and then right click on the package Move to archive folder by appending Retired to the existing package name to know package is retired.

    If you have multiple packages,moving one by one is not easy thus you require something like script or tools.

    Moving package using script may require to get the Source folder ContainerID number of  the packages(Folder of the package)  and Destination Folder ContainerID(Archival folder ID).

    Here is the SQL query for the list of moving packages to know their Source Folder ContanerID.

     image

    From the package clean up report,if you get multiple packages,just place them in IN condition separated by comma (,).

    I have packageID cen00004 which i need to move to archive folder with containerID=4 from SQL query below

    select  B.ContainerNodeID,B.NAME,A.InstanceKey from dbo.FolderMembers a,.dbo.Folders b where
    a.ContainerNodeID=b.ContainerNodeID and b.Name like '%archive%'

    Replace the folder name if you have other one.

    Now we have list of packages with their source ContainerNodeID(which is nothing  but the package FolderID).

    Create a VB script with below syntax with input of all package IDs separated by commas with their source folder and destination folder.

    Note : Please replace quotes (‘”) as they are replaced by fancy.

    Option Explicit
    'On error resume next

    Dim strSMSServer, strSMSSiteCode, strPackageIDs
    Dim intSourceFolder, intDestFolder, intObjectType
    Dim loc, objSMS
    Dim objFolder
    Dim arrPackageIDs
    Dim retval

    strSMSServer   = "SCCM server Name"
    strSMSSiteCode = "SiteCode"
    strPackageIDs  = inputbox("Please input packageIDs separated by commas","List of packages to be moved")

    intSourceFolder =inputbox("Please input Source folder ContainerID number", "Source ContainerID")  ‘This ID is what you see in above SQL query to move all packages from the same folder test =1.
    intDestFolder   =4 'Destination Folder for Archived packages :In this case,My archive package folder is 4.

    intObjectType   = 2  '2=Package for type of object .This scripts works only for standard software distribution packages.

    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
        msgbox Err.Description
    End If

    MSGBOX "Script is completed"

    You may get multiple packages with different source Folders.So you will have to run the script to move bulk packages from each source folder to Destination at one go.

    It is better than moving one by one package each time.

    Hope it helps!

    Archive folder configuration Manager ContainerNodeID FolderMembers MoveMembers SCCM SCCM Script move packages Script move packages in SCCM
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    SCCM SQL Report – Compare Installed Apps on TWO Different Computers

    July 13, 10:35 am

    Optimize Your Intune Workflow with a Powerful Browser Extension

    March 22, 10:39 am

    Migrate Microsoft 365 Updates from SCCM/MECM to Intune for Co-Managed Devices

    February 11, 9:50 pm

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2025 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.