Content Library Cleanup Error – This content library cannot be cleaned up

Prajwal Desai
Posted by Prajwal Desai

While running the content library cleanup tool on a SCCM DP, you might encounter a common error. This content library cannot be cleaned up right now because package is not fully installed.

In this post, I will cover some info that should help you to deal with this error. If you want to know more about SCCM content library tool, read this post – https://www.prajwaldesai.com/sccm-content-library-cleanup-tool/

What is Content Library cleanup tool – It is a command line tool. Using this tool you can delete orphaned content on distribution point. However this tool has a known issue and Microsoft has acknowledged it.

When any package or deployment has failed, or is in progress, the tool might return the following error. This content library cannot be cleaned up right now because package <packageID> is not fully installed.

According to Microsoft, there’s no workaround for this issue. The tool can’t reliably identify orphaned files when content is in progress or has failed to deploy. The tool won’t allow you to clean up content until you resolve that issue.

Content Library Cleanup Error

Let me show you the exact content library cleanup tool error with the screenshot. I have seen this question a lot of times in community forums. I hope this post will be useful for answering such questions.

In my case I got the below error when I attempted to clean the content library on a remote SCCM distribution point. System.InvalidOperationException: This content library cannot be cleaned up right now because package <packageID> is not fully installed.

This content library cannot be cleaned up right now because package is not fully installed.
This content library cannot be cleaned up right now because package is not fully installed.

This content library cannot be cleaned up right now

If you see the above error, the most common fix is to redistribute the problematic package to distribution point. Not only that you must ensure the package is fully distributed to the distribution point. You may also first remove the package from distribution point and distribute the package back. After that re-run the content lib cleanup tool.

The package ID that was highlighted by the tool was a package that wasn’t present on my primary distribution point server. The remote DP had this package and I am not sure why.

When you look at the package ID you cannot know the name of package unless you run the below command.

Get-CMPackage -ID “packageid” | Select -expand Name

The package was a CCleaner Removal script that I had created when we wanted to remove CCleaner from systems (Floxif Malware).

find the package name using the package ID

In addition to the above method, you can also use the below query to find the name of package.

Select * from smspackages where pkgid=’packageid’

So if you find any package that is not required, you can delete it from distribution point.

delete the package from database

Running the tool again did not result in any error.

Finally I ran the tool in content library cleanup tool in /delete mode on remote DP and all the orphaned content is deleted.

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

Content Library Cleanup Error

The log file created in temp folder should show the exact amount of space freed on the distribution point server.

Content Library Cleanup Error
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.