So now that ConfigMgr CB 1702 is with us, in this post I am going to focus on one of the nice new features, namely the Content Library Cleanup tool – ContentLibraryCleanup.exe.
Maintenance.. Maintenance.. & More Maintenance
Prior to CB 1072 when content was orphaned on a distribution point, the process of removing this redundant data was in the hands of the ConfigMgr admin. If you are distributing a significant number of packages, over time the amount of redundant data can be significant and the process of cleaning this data up manually can be both difficult and time consuming to orchestrate in a large environment.
They Listened
In the latest current branch release, the product team have included a little gem to take care of this part of your essential maintenance toolkit, namely the ContentLibraryCleanup.exe tool.
The ContentLibraryCleanup.exe Tool
This new utility is a command line based program that compares the content of distribution points with the packages currently deployed from a specified site server. This way a map of the content is built up and the redundant objects are flagged by the tool for deletion.
Running the tool is a simple process;
- Obtain the ContentLibraryCleanup.exe from the following directory on your site server in your primary site – %CM_Installation_Path%\cd.latest\SMSSETUP\TOOLS\ContentLibraryCleanup\
- Open a Command Prompt / PowerShell Console and use the utility using the following format to get an estimate of how much data can be saved;
– ContentLibraryCleanup.exe /dp “Name of your distribution point to clean” /ps “FQDN of the primary site that the distribution point belongs to” /sc “Site code that the DP belongs to”
Content Library Cleanup Tool – Analysing
Failed to Deploy
Where content is found which failed to distribute, you might receive an error like the below;
In this instance you will need to remove the distribution point from the identified package.
The Microsoft documentation notes this in the known issues section;
Known issue When the tool is run, an error like the following might be returned when any package or deployment has failed, or is in progress:
- System.InvalidOperationException: This content library cannot be cleaned up right now because package is not fully installed.
Workaround: None. The tool cannot reliable identify orphaned files when content is in progress or has failed to deploy. Therefore, the tool will not allow you to clean-up content until that issue is resolved
Huge Potential For Savings
So after a quick analysis of data on a test DP, I was surprised to see the following;
So in an instance whereby a small branch office DP serving 100 clients had just shy of 40GB’s of wastesd space, just think about the potential to automate the process of cleaning up your entire estate and the resulting disk space savings.
Cleaning Up Your Distribution Points
Running the tool to silently automate the deletion​ of redundant content is just a matter of including the /delete & /q switches.
After the cleanup process has completed you will have a log similar to the one below;
Looking at the server in question we can now verify the space savings;
Pre – Content Library Clean Up
Post – Content Library Clean Up
More Information
More info on this addition to ConfigMgr can be found on Mirosoft’s documentation site – https://docs.microsoft.com/en-us/sccm/core/plan-design/hierarchy/content-library-cleanup-tool
Tool is not really helpfull as it will not work during those messages about “package not fully transfered..:”. In an environment with more than 250 DPs, theres too much manual work to do before even getting an information about how much space can be cleaned.
Analysis mode should work even though some packages are not fully transfered.
Sorry, but in my opinion, this tool has to be improved for enterprise use.
Hi Joern,
Granted it does have some limitations, but this tool is not long out of its technical preview state and it does offer significant space savings in quite a lot of everyday environments. I would urge you to submit feedback and suggestions on the SCCM user voice site as the product team are very keen to hear both the good and bad points of work they are doing (https://configurationmanager.uservoice.com/forums/300492-ideas).
Maurice
Hi Maurice,
I’m getting a rather peculiar error after the “Loading distributed packages from provider…” step:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadOrphanData(Boolean whatIfMode)
  at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.Cleanup(Boolean whatIfMode, Boolean quietMode, String logDir)
  at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[] args)
I’ve thrown a message out to Microsoft regarding it but I was wondering if you saw this during any of your tests?
Hi Kevin,
That’s not something I have seen in testing. Let me know if you don’t get any response on this and I will raise a query on it.
Maurice
Hi Maurice
Any suggestions for working with the “System.InvalidOperationException: This content library cannot be cleaned up right now because package is not fully installed.” error?
I’ve currently getting this error with the package identified being the default Configuration Manager Client Package. I had an issue with this package distributing previously and I can’t remember exactly what I did to fix it but it involved various methods of resetting/re-generating. I haven’t had any issues with this package recently and certainly since the SCCM 1702 upgrade it appears to have been re-distributed ok but is now causing issues with the ContentLibraryCleanup Tool.
Thanks in advance
Hi Paul,
Have you tried removing the offending package from the DP which you have issues with rather than just re-distributing it?. You could also use the Content Library Explorer from the SCCM Toolkit (https://www.microsoft.com/en-us/download/details.aspx?id=50012) to verify the package contents on your distribution group as a troubleshooting step.
Maurice
Hi Maurice, thanks very much I was able to resolve my issue thanks to your suggestion of the Content Library Explorer (and it turned out the offending package was not the Configuration Manager Client Package).
In regards to Error: This content library cannot be cleaned up right now because package is not fully installed. I was able to resolve by this issue by deleting the package in questionon the SQL Box by Query on “dbo.SMSPackageHist” with command :
select * from SMSPackagesHist where PkgID like ‘%xxx00204%’
Deleting it with
delete from SMSPackagesHist where PkgID like ‘%xxx00204%’
Ran the Cleanup Tool again and was able to get past this point. Use /delete /q and feed up 88 gigs of space!
Hi Jeff,
Editing the SQL database directly is not a Microsoft supported action, just FYI. You should have been able to get around this issue by removing the DP from the selected package DP list. But glad to see you managed to save 88Gb of space :).
Maurice
Hi, great article but I get an error about the user does not have the Full Administrator RBAC role and All Scope to run the tool. I’m using an Admin user which has the AD Group assigned to SCCM as Full Administrator. I don’t see where I can set the scope to ALL. Any ideas?
Hi Mark,
You can check/set the security scopes in the ConfigMgr console. If you go to Administration – Security – Administrative Users – Pick the AD Group – Right Click – Properties – Security Scopes.
Maurice