SCCM Content Library Cleanup Tool

Prajwal Desai
Posted by Prajwal Desai

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.

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 ?.

Ad imageAd image

This tool was first introduced in Technical Preview version 1612. But now you should find this tool with every release of SCCM current branch.

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

Tool Usage

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.

Exploring SCCM ConfigMgr Content Library Cleanup ToolTo 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.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

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.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

Furthermore when I check the log file, it states the same thing that there is no content that can be freed.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

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>

Exploring SCCM ConfigMgr Content Library Cleanup Tool

The log file shows approx 0 bytes were freed. Since there was no stale content to delete, the message is correct.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

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.

Exploring SCCM ConfigMgr Content Library Cleanup Tool

The output shows approx 137,11,835 bytes of data can be freed.

Content Lib Cleanup Tool usage

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.

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.

Content Lib Cleanup Tool usage

Video Tutorial – Content Library Cleanup Tool

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

Share This Article
Prajwal Desai
Posted by Prajwal Desai
Follow:
Prajwal Desai is a Microsoft MVP in Intune and SCCM. He writes articles on SCCM, Intune, Windows 365, Windows Server, Windows 11, WordPress and other topics, with the goal of providing people with useful information.
72 Comments