If you want to clean up the content library in SCCM, you must use the Content Library Cleanup tool. The content library clean up tool deletes the orphaned content from SCCM distribution point.
In this post I will cover what is content library cleanup tool, it’s requirements and how to use it. You can find ContentLibraryCleanup.exe in CD.Latest\SMSSETUP\TOOLS\ContentLibraryCleanup on the site server.
Table of Contents
What is SCCM Content Library Cleanup Tool
The content library clean up tool is basically a command line tool. Using this tool you can delete orphaned content on distribution point.
What is orphaned content on distribution point ?. Any content that is not associated with SCCM application or package is considered as orphaned content. Deleting the orphaned content is important because that will save disk space on your distribution points. It doesn’t make sense to keep orphaned content on a distribution point ?.
SCCM Content Library Cleanup Tool Requirements
Before you perform content library cleanup, here are some of the requirements to use this tool.
You can run the content library cleanup tool directly on the computer that hosts the distribution point. Most of all you can also run the tool remotely from another server. 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. Otherwise you will see the below error.
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.
Content Library Cleanup Tool Command Line Options
As I mentioned before the SCCM content library cleanup is a command line tool. So this tool comes with multiple switches and the below table lists all of them.
|Content Library Cleanup Tool Switch||Description|
|/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|
Most of all the tool can be run in two modes What-if mode and Delete mode. When you run the tool in what-if mode, the tool finds orphaned content that can be deleted from DP. However the content is not deleted.
A log file records all this information. You can grab the log file from Temp folder.
When you run the tool in delete mode, the orphaned content is deleted from DP’s content library. Therefore it is recommended that you run the tool in What-If mode first and review the resulting log file before you use the /delete switch.
How to Use Content Library Cleanup Tool in SCCM
Here are the steps to use content library cleanup tool in SCCM.
First of all locate the content library cleanup tool. Look for ContentLibraryCleanup.exe in CD.Latest\SMSSETUP\TOOLS\ContentLibraryCleanup on the site server.
To run this tool on a distribution point server, copy this tool to the machine. Run the command prompt as administrator. Run the command ContentLibraryCleanup.exe without any switches and you should see the tool usage options.
To perform the content lib clean up run the below command on a distribution point server :-
ContentLibraryCleanup.exe /dp DP FQDN /log <folder path>
In my case the server has almost no orphaned content on it. This is my lab server so when I run the command in whatifmode, I see very small amount data that is actually stale. As a result there is nothing much to delete from distribution point and hence I see a message that there is no orphaned content that can be freed.
Furthermore when I check the log file, it states the same thing that there is no content that can be freed.
In case you got stale content on your distribution point server, you must run the tool in delete mode.
ContentLibraryCleanup.exe /delete /dp <DP FQDN> /log <log file path>
The log file shows approx 0 bytes were freed. Since there was no stale content to delete, the message is correct.
Content Library Cleanup Tool in Action
Now I am going to run content library cleanup on the distribution point server that is in my prod environment. First I run the tool in what-if mode. Type Y to proceed.
The output shows approx 137,11,835 bytes of data can be freed.
Finally I run the tool in /delete mode on prod DP server and all the orphaned content is deleted. I have read some comments where some people got errors while running the tool. I will cover the errors in a separate post.
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.
Video Tutorial – Content Library Cleanup Tool
Here is a video tutorial that shows how the configuration manager content library cleanup tool works.