Exploring SCCM ConfigMgr Content Library Cleanup Tool

31

This post talks about exploring SCCM ConfigMgr content library cleanup tool. The content library clean up tool deletes the orphaned content from SCCM distribution point. Any content that is not associated with SCCM app/package is considered as orphaned content. This tool was introduced in Technical Preview version 1612. The content library clean up tool is a command line tool. We will see how this command can be used to delete orphaned content and it’s usage as well. As per Microsoft this tool version will cease to function after March 1st 2017. The tool will be later included with release of Current Branch or a production ready out-of-band release.

You can run the content library cleanup tool directly on the computer that hosts the distribution point. Most of all you can run the tool remotely from another server. However you can run the tool against a single distribution point at a time. If you are running this tool then ensure you are a Full Administrator on the Configuration Manager hierarchy.

Tool Usage – The tool can be run in two modes What-if mode and Delete mode. When you run the tool in what-if mode it finds out the orphaned content that can be deleted from DP. However the content is not deleted. It logs about the content that can be deleted in a log file. By default the log file is located in user’s temp folder. This log file is opened automatically once the tool is run successfully. When the tool is run with /delete switch, the orphaned content is deleted from DP’s content library. Therefore it is recommended that you run the tool in What-If mode and review the resulting log file before you use the /delete switch.

The tool comes with multiple switches.

SwitchSwitch Info
/delete(Optional) Delete the content from DP
/q(Optional) Quiet mode, suppresses all prompts
/dp <DP FQDN>(Required) Specify distribution point FQDN
/ps <Primary Site FQDN>(Optional) Specify the FQDN of primary site the distribution point belongs to
/sc (site code)(Optional) Specify the site code of primary site the distribution point belongs to
/log(Optional) Outputs the result in a log file

 

Here is a video tutorial that shows how the configuration manager content library cleanup tool works.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

Let’s explore the configmgr content library cleanup tool. If you have installed the SCCM tech preview 1612, you will find this tool under %CM_Installation_Path%\cd.latest\SMSSETUP\TOOLS\ContentLibraryCleanup\ folder.

Exploring SCCM ConfigMgr Content Library Cleanup ToolI have copied the tool to a folder located on desktop. Run the command prompt as administrator and change the path to where tool is located. Run the command ContentLibraryCleanup.exe, the tool usage data is displayed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolThe below command is executed on a distribution point server. This server has got very less content on it. So when i run the command in whatifmode, as a result it identifies and outputs the amount on data (in bytes) that can be deleted from content library on distribution point server. The below screenshot shows that there is no orphaned content that can be freed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolThe below log file screenshot shows there is no content that can be freed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolIn this case running the tool in delete mode won’t delete any content.

ContentLibraryCleanup.exe  /delete /dp <DP FQDN> /log <log file path>

Exploring SCCM ConfigMgr Content Library Cleanup ToolThe log file shows approx 0 bytes were freed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolI copied this tool to my distribution point server located on prod environment. Running the tool in what-if mode. Type Y to proceed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolThe output shows approx 137,11,835 bytes of data can be freed.

Exploring SCCM ConfigMgr Content Library Cleanup ToolIn conclusion I have run the command with /delete mode on prod DP server and I confirm it works well. Let me know if you have tried this tool and how was it in comments section.

Exploring SCCM ConfigMgr Content Library Cleanup Tool Note – If you use the older version of the content library tool, then you end up seeing the error. This version of this tool is expired and cannot be used.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

  • Hi,
    How does the tool look for orphaned content? What exactly does it check and compare to id that a content is actually orphaned. Just interested in knowing what goes on under the hood.

  • Had some good success, but now getting this on the majority of DP’s when running the tool.
    System.Management.ManagementException: Unable to load valid packages. Please che
    ck the specified site server location and ensure you have access to the site ser
    ver and the provider. —> System.Management.ManagementException: Quota violatio
    n
    at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStat
    us errorCode)
    at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.Mo
    veNext()
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Load
    PackageToContentFromProvider()
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Load
    ValidContentData()
    — End of inner exception stack trace —
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Load
    ValidContentData()
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..cto
    r(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
    args)

  • I have SCCM 2012 R2. I would like to be able to run ConfigMgr Content Library Cleanup Tool but obviously my version doesn’t have it. Do I have to install “Technical Preview version 1612” or later to get my hands on ContentLibraryCleanup.exe, or is it available for download elsewhere. As you stated the tool can be run on SCCM 2012 R2, how can I obtain it?

  • Not much of an error but more of this tool not working correctly…Reported some orphaned content and I was confirming the deletion one by one but then it didnt look right.

    On the next package I deleted, I looked in the SCCM console and it was successfully distributed to the DP i was running the tool on. I went ahead and confirmed the deletion of the next orphaned item and then did a validate of the package on that distribution point and came back red…content error.

    So what exactly is this tool doing or how is it determining the content if orphaned if it is deleting legitimate things causing the validation to fail where it successfully distributed before.

  • I am getting this error while running from DP as well as Primary server.
    Gathering information…
    Loading information from distribution point…
    System.Management.ManagementException: The tool cannot be run using the current
    user, because the current user does not have the ‘Full Administrator’ RBAC role
    and ‘All’ scope.
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..cto
    r(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
    args)

  • Hi
    Thanks for a nice post!
    I have successfully running this tool on DPs
    However it failed on Secondary Site with DP role installed. I know this tool cannot run on Primary site, but not on Secondary either?

  • I am encountering the same problem when trying to run this tool.
    I get the error “…cannot be cleaned up right now because package “PR000F5” is not fully installed.
    How do I go about making sure that package is seen as complete or working on it please?
    (As far as I can see the package is correctly distributed as it has been running fine).
    thanks in advance

  • I get this erro “System.InvalidOperationException: This content library cannot be cleaned up righ
    t now because package BGR0006D is not fully installed.” I received this error on a couple of other packages and removed them. However, there is no package with this ID in my system. When I run
    PS BGR:> Get-CMPackage | select PackageID

    PackageID
    ———
    BGR00001
    BGR00003
    BGR00009
    BGR0000C
    BGR00014
    BGR00015
    BGR0001D
    BGR00026
    BGR0002A
    BGR00030
    BGR00035
    BGR00047
    BGR00048
    BGR0005A
    BGR0005F
    BGR00060
    BGR00061
    BGR00062
    BGR00067
    BGR00068
    BGR00069
    BGR0006A
    BGR0006F
    BGR00075
    BGR0007A
    BGR0008D

    As you can see, no package BGR0006D. Any ideas what to do now? Thanks for any assistance.

    • Try SQL way.. Use the below queries and see if the packages exists.
      Select * from smspackages where pkgid=’SRV000CD’

      or

      select * from pkgstatus where id=’SRV000CD’ AND sitecode=’XXX’

  • Can the tool be ran if you are on an older version of CM?
    I’m on CM 1606.
    What would the effect be if you run the tool in this case?

      • I tried running on SCCM 2012 Infra and getting below error message on Dp as well as Primary SCCM server.
        I am already part of Administrator on both the servers.

        Gathering information…
        Loading information from distribution point…
        System.Management.ManagementException: The tool cannot be run using the current
        user, because the current user does not have the ‘Full Administrator’ RBAC role
        and ‘All’ scope.
        at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..cto
        r(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
        at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
        args)

  • Great preview of a useful tool. I’m curious, will the formatting of the bytes that will be deleted be fixed in the Current Branch version? 137,11,835 should be 13,711,835 bytes. Minor annoyance at most, though.

  • So this tool is only in technical preview release now but is to be included in next the production release?

    I can see this tool freeing up a lot of diskspace for some of our customers distribution points.

      • Hi Prajwal, actually the tools says that a package/program is not fully downloaded and stops working. The same happens when a package/program is in a failed state.

        • Hi, thanks for the presentation, I agree with that point. If the package is not fully installed, the tool crash:System.InvalidOperationException: This content library cannot be cleaned up right now because package VAL01FC6 is not fully installed.

  • This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More

    >