How to use SCCM Content Library Cleanup Tool

Benoit LecoursSCCM20 Comments

Starting with SCCM 1702, a new command line tool is available to remove content that is no longer associated with any package or application from a distribution point. The SCCM Content library cleanup tool (ContentLibraryCleanup.exe) can help you save up valuable space in a specific distribution point content library.

The tool will delete content from the library based on the specified distribution point when the tool is run.

SCCM Content Library Cleanup Tool Requirements

  • You can run the content library cleanup tool directly on the computer that hosts the distribution point or remotely from another server
  • You can run the tool from a single distribution point at a time
  • You will need to have Full Administrator RBAC Role and the “All” Security scope in the Configuration Manager hierarchy

Running the Tool

You can find ContentLibraryCleanup.exe in the SCCMInstallationDir\cd.latest\SMSSETUP\TOOLS\ContentLibraryCleanup\ folder on the primary site or central administration site.

You can run the tool in 2 modes: What-If mode and Delete mode.

We will start by not specifying the /delete switch. The tool will run in What-If mode. This mode allows identifying the content that would be deleted from the distribution point.

  • On your Primary site, open an administrative command prompt and go to the ContentLibraryCleanup folder (see full path above)
  • Command : ContentLibraryCleanup /dp SCCM2012
    • The tool will check the content library on the SCCM2012 machine which is my distribution point (in What-If mode)
SCCM Content library cleanup tool
  • We encounter the following error:
SCCM Content library cleanup tool

System.InvalidOperationException: This content library cannot be cleaned up right now because package 10000004 is not fully installed.
at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadDistributedPackagesFromProvider()
at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadValidContentData()
at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..ctor(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[] args)

This error happens because the package ID 10000004 has content replication issues.

  • If you have this error, open the SCCM console and fix the replication issue on the specified package ID and rerun the tool
SCCM Content library cleanup tool
  • The tool runs and the log file is written to the temp folder of the user account that runs the tool. The log file will open automatically
SCCM Content library cleanup tool
  • Review the log file to see what could be deleted if the /delete switch is ran
  • When you’re fine with it, run the following command to delete the content:
  • ContentLibraryCleanup /DP SCCM2012 /Delete
    • Before deleting each file, you must confirm that the file should be deleted (Yes, No, All)
SCCM Content library cleanup tool

All command line switches for the SCCM Content library cleanup tool can be found on the Technet Documentation.

20 Comments on “How to use SCCM Content Library Cleanup Tool”

  1. Our DP is on Primary Server and getting Error:-

    Loading distributed packages from provider…
    Because this distribution point is co-located with its site server, packages may
    correctly exist in the content library that are not distributed to the distribu
    tion point. Package deletion has been disabled.
    System.NullReferenceException: Object reference not set to an instance of an obj
    ect.
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Load
    OrphanData(Boolean whatIfMode)
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Clea
    nup(Boolean whatIfMode, Boolean quietMode, String logDir)
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
    args)

    1. I’m looking for help with this same message. Our original DP was setup on the site server but has since been moved. The DP role was removed from the site server, but SCCMContentLib remained. I reinstalled the DP role and ran ContentLibraryCleanup.exe but get this message. There are no packages distributed to the DP, but SCCMContentLib is still using 275 GB. I’d like to free up this disk space.

  2. I have tried to use content library clean-up tool from DP and getting this below error. I run with admin privilege on servers and sccm and run directly on DP.
    Unable to load valid packages. Please check the specified site server location and ensure you have access to the site server and the provider

  3. This may be an oddball question but, I cleaned up a couple of packages that were corrupted. I want to redistribute it to the same dp I cleaned them from.
    The distr.log just keeps saying ‘attempting to delete package xxxx, failed because the package is not there’.
    To add them back to the distribution, I click on the package, select deploy and then select the distribution point (it correctly shows the dp who doesn’t have it) it goes thru the motion, but it doesn’t get distributed.
    Do I just need to wait longer?

  4. It would be great if it actually told you what it was deleting, instead of some obscure reference to a guid that only SCCM knows about. Would writing the real file path out to the console really be that hard?

    1. You can script it with powershell

      foreach($line in (Get-Content .\DP.txt))
      {
      .\ContentLibraryCleanup.exe /dp $line /delete /log .\log /q
      }

      Put this script in folder with ContentLibraryCleanup.exe and a file DP.txt wich contains all your DP

      1. i think one issue is that when you have a long runtime for the tool you run into issues with packages that start getting transfered to the DP (like SCEP Definitions and such) and then the tool won’t work… anyone has a good idea how to solve that problem? i guess with 19xx its not an issue because of the maintenance mode but i have DPs in Argentina the tool takes a couple of hours to run and I will never be able to cleanup the DP :/

  5. 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)

  6. The cleanup tool keeps getting hung up for me because I have a handful of packages that don’t have content associated with them. I need this stuff as they are scripts with no content that I have deployed…anyone aware of a workaround?

  7. I got the same error you got at first although I do not have anything with the Package ID it is referencing. Any ideas on how to move forward?

    1. I think you might need to write your own PowerShell to do that. I was looking into doing that a while ago but never got around to it.

  8. Pingback: How to use SCCM Content Library Cleanup Tool |

Leave a Reply