SCCM Content Library Cleanup Tool

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

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.

72 Comments

  1. Avatar photo Thomas Hopkins says:

    Hello,

    I have just used this and worked great, thank you! However, I also need to clear down the SCCM Content Library folder on a additional drive on the same SCCM server. The additional drive is a WSUS drive but it has a SCCM content library folder which is slowly taking up all the drive space. How can I clear this?

    Many thanks,
    Tom

  2. Avatar photo Thomas Hopkins says:

    Hello,

    Just used this and it worked great so thank you! I would like to clear the SCCM content library folder on our WSUS drive as that is starting to fill in storage slowly. How can I do this as it’s just a additional drive on our SCCM server?

    Kind regards,
    Tom

  3. How would I run this if my content is on a network share?

  4. Avatar photo Ricky Meyer says:

    Prajwal, I only have 1 site, how do I clean up the SCCMContentLib folder? Is it safe to just delete old folders with a single site? So far from my research, you can’t run the tool on a single server. Thanks

  5. Hello Prajwald,
    I have cloud based DP’s and a formal MS manual indicates that “tool doesn’t support a content-enabled cloud management gateway”.
    Is there a way to clean cloud based DP’s?
    Thanks
    ido

    1. Avatar photo Prabakaran says:

      Hi Ido,

      Have you found any solution for the requirement? Even I have similar requirement.

      Regards,
      Prabakaran

  6. Avatar photo Nandu Ditto says:

    Hi Prajwal,

    The command is working fine.
    Initially after analyzing I get lot of invalid content appearing before orphaned content.
    Is it OK to delete those invalid content ?

  7. Hi…..I tried running the content cleanup command but am still getting 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.

    I have Full Admin access to SCCM Admin, but am still getting the error . It is 3 days now. Please suggest.

    Thanks

    1. So, I know this was a year ago but I ran into the same problem and what I found online was people saying its a rights issue but what I found was I just needed to define the /ps and /sc and once I did that it worked as expected.

  8. Hello,

    Just following this guide to reclaim space and for general maintenance.

    Any advice with the following output message will be appreciated?

    Analyzing local files, 93.84% complete…
    Analyzing local files, 98.18% complete…
    Analyzing local files, 100.00% complete…
    Loading package data from provider…
    Loading local package data…
    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.
    The following contents may be orphaned. They are not part of any package–the pa
    ckage may have been deleted on the site server:
    Delete 85b23fd3-bddf-43f2-a8b3-5cda9e3a88c0: ‘y’ = yes / ‘n’ = no / ‘a’ = yes to
    all / ‘s’ = skip all ::

    1. This is the prompt to proceed with deleting the orphaned content. You can press ‘y’ to go one by one, or ‘a’ to let the tool delete all of that kind of orphaned content. When it finds another kind of OC, it’ll ask you again even if you chose ‘a’ before.

      You can also run the tool with the /q switch to bypass all prompts and delete everything it finds.

  9. Hi Prajwal,
    I need one clarification . By using this tool what it can be delete and how to check what data deleted. If it deleted or not? Where we can find this in background.

    Is there any important data deleted

  10. I just want to say that last time somebody ran this tool on out primary site server and it deleted a lot of used INI file from DataLib folder. As I checked on MS from it’s not recommended to do on primary site server. What is your opinion in this case?
    Thank you for your help in advance.
    David

  11. Hello Prajwal, Thank you so much for all your work in SCCM.
    I could run the tool in ‘What if’ mode and received the log correctly but however I have problem running this tool in ‘Delete mode’ and as I understand it is because my DP is also a Primary Site server. Is there a way to clean up the content library folder in this case on my Primary site server? It is expanding and I have deleted few old applications but it doesnt help in clearing up the space. Can you please advise?

  12. Avatar photo Michael Gerressen says:

    Hi Prajwal,

    Recently in my environment i’m experiencing some troubles with orphaned files on my DP’s.
    Every time we run this command, we can see that it cleaned up a lot of Gig’s, and all from Windows Update deployment packages.
    We use the option ” Enable binary differential replication” for our deployment packages. Could it be that this option shouldn’t be use in cases where the entire package changes regularly (all superseded updates are deleted from the deployment packages).

    Thanks in advance.
    Regards.
    Michael

  13. if not mistaken, it cleaned up kb, not bytes

  14. Avatar photo Ase Karlsson says:

    Hi Prajwal,

    SCCM 2002 with all updates installed (all roles on a single server).
    When running this tool using cmd as Administrator (domain admin) on the local server I get the following error.
    What should I look for and try to fix this?

    Thanks,
    Ase

    Analyzing local files, 99,99 % complete…
    Analyzing local files, 100,00 % complete…
    Loading package data from provider…
    System.Management.ManagementException: Unable to load valid packages. Please check the specified site server location and ensure you have access to the site server and the provider. —> System.Management.ManagementException: Call cancelled
      at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
      at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
      at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadPackageToContentFromProvider()
      at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadValidContentData()
      — End of inner exception stack trace —
      at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary.LoadValidContentData()
      at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[] args)

    1. “ensure you have access to the site server and the provider” – Did you see this ?. What account are you using to run this tool.

      1. Avatar photo Ase Karlsson says:

        Hi Prajwal,
        I logon to the server using RDP as Domain Administrator and then i start the CMD window as Administrator, so I feel that the rights should be enough. What does “Provider” mean in this content?

        Thanks,
        Ase

        1. Avatar photo Ase Karlsson says:

          Tried to do a Site Reset on the server and also tried to run the tool from a workstation instead of the actual server, but with the same result. Anyone with ideas?

          //Ase

  15. Avatar photo Charly Reber says:

    Hi Prajwal
    Thank you very much for allways sharing your knowledge and expertise,
    you have for many times now been a real help when in need!
    I just wanted to let you know. 🙂

    Take care and thanks again!

    Charly

    1. Avatar photo Prajwal Desai says:

      Thank you 🙂

  16. Avatar photo James McDermott says:

    Thanks Prajwal, I have been using this tool successfully for some time but as of the last few months I now receive a Windows error message “This app can’t run on your PC. To find a version for your PC check with the software publisher”. This happens if I try to launch from CMD or File Explorer. I can find next to no information regarding this fault online. Any help appreciated! Thanks. James.

    1. Avatar photo A Mahmood says:

      I am having the same issue — Prajwal please help.

    2. Ok, I need some details such on what server are you running this tool, what is the SCCM version and are apps blocked from running on the servers ?.

      1. Hi Prajwal. Did you ever find a fix for this? I’m having the same issue. I’m running EndPoint ConfgMgr ver 2002 on Windows Server 2012 R2.

        1. Avatar photo Prajwal Desai says:

          No steve, i have used this tool numerous times and i have never come across that error. I am unable to reproduce that error in my lab setup. I have tested the tool in my prod setup and it works fine.

          1. Thanks for the quick reply Prajwal. Believe it or not in the short time since I posted my comment I managed to figure out the issue. For some reason, the ContentLibraryCleanup.exe on my server is old. I downloaded the current ISO from Microsoft, extracted the latest file and copied it to my primary server and it worked without the error.
            So this begs the question… why aren’t the files on my server current? This makes me concerned that all the other tools and such are outdated too. I just recently updated to 2002. Doesn’t the upgrade update the files in the cd.latest folder? Any ideas? 🙂

  17. Hi and thank you very much Prajwal, the tool is working as described. I have still 140 GB of Data. Another “problem” directory is source directory for the windows 10 updates. This seems to be also too large, there are 75 GB of Data. Is there also a way to clean it up with a tool? Greetings from Germany, Stefan

    1. Avatar photo Prajwal Desai says:

      The old updates shall be removed by ConfigMgr manager.

  18. Avatar photo mohammed irfan siddiqui says:

    Dear Rrajwal,

    I checked in the path, the file is Content Library Cleanup file is there , but it seems to be corrupted, it is only 1KB and seems to be notepad, please let me know , from where can I download the Content Library Cleanup file ?,

  19. Avatar photo lokesh kumar says:

    sccm 1606 have content library cleanup tool not available under provided location. Please suggest me to download.

  20. Avatar photo lokesh kumar says:

    content library cleanup tool download is not available in sccm 1606 Then how i can download tool.

  21. Hi,
    How does the tool look for orphaned content? What exactly does it check and compare to id that a content is actually orphaned. Just interested in knowing what goes on under the hood.

  22. Avatar photo Gwyn Jones says:

    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)

    1. I have the same problem. Were you able to find a solution?

  23. Avatar photo John Davis says:

    I have SCCM 2012 R2. I would like to be able to run ConfigMgr Content Library Cleanup Tool but obviously my version doesn’t have it. Do I have to install “Technical Preview version 1612” or later to get my hands on ContentLibraryCleanup.exe, or is it available for download elsewhere. As you stated the tool can be run on SCCM 2012 R2, how can I obtain it?

    1. Install tech preview release 1612 and above and grab the tool. Copy the tool to SCCM 2012 R2 server and use it on any DP’s.

  24. Not much of an error but more of this tool not working correctly…Reported some orphaned content and I was confirming the deletion one by one but then it didnt look right.

    On the next package I deleted, I looked in the SCCM console and it was successfully distributed to the DP i was running the tool on. I went ahead and confirmed the deletion of the next orphaned item and then did a validate of the package on that distribution point and came back red…content error.

    So what exactly is this tool doing or how is it determining the content if orphaned if it is deleting legitimate things causing the validation to fail where it successfully distributed before.

  25. I am getting this error while running from DP as well as Primary server.
    Gathering information…
    Loading information from distribution point…
    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.
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..cto
    r(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
    at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
    args)

    1. Isn’t that error very clear ?. The tool cannot be run using the current user, because the current user does not have the ‘Full Administrator’ RBAC role and ‘All’ scope – Check the account permissions that you are using to run this tool.

  26. Avatar photo Thinh Ngo says:

    Hi
    Thanks for a nice post!
    I have successfully running this tool on DPs
    However it failed on Secondary Site with DP role installed. I know this tool cannot run on Primary site, but not on Secondary either?

  27. I am encountering the same problem when trying to run this tool.
    I get the error “…cannot be cleaned up right now because package “PR000F5” is not fully installed.
    How do I go about making sure that package is seen as complete or working on it please?
    (As far as I can see the package is correctly distributed as it has been running fine).
    thanks in advance

  28. I get this erro “System.InvalidOperationException: This content library cannot be cleaned up righ
    t now because package BGR0006D is not fully installed.” I received this error on a couple of other packages and removed them. However, there is no package with this ID in my system. When I run
    PS BGR:> Get-CMPackage | select PackageID

    PackageID
    ———
    BGR00001
    BGR00003
    BGR00009
    BGR0000C
    BGR00014
    BGR00015
    BGR0001D
    BGR00026
    BGR0002A
    BGR00030
    BGR00035
    BGR00047
    BGR00048
    BGR0005A
    BGR0005F
    BGR00060
    BGR00061
    BGR00062
    BGR00067
    BGR00068
    BGR00069
    BGR0006A
    BGR0006F
    BGR00075
    BGR0007A
    BGR0008D

    As you can see, no package BGR0006D. Any ideas what to do now? Thanks for any assistance.

    1. Try SQL way.. Use the below queries and see if the packages exists.
      Select * from smspackages where pkgid=’SRV000CD’

      or

      select * from pkgstatus where id=’SRV000CD’ AND sitecode=’XXX’

  29. Can the tool be ran if you are on an older version of CM?
    I’m on CM 1606.
    What would the effect be if you run the tool in this case?

    1. I have tested the tool on SCCM 2012 R2 and it works well. Not sure about the versions older than R2. But yes, the tool should work fine on CM1606

      1. Greate, I’ll test it today.
        Also, will this only work on DP’s or also on the ContentLibrary on the Site Server?

          1. Only on a Distribution Point or also for the ContentLibrary on the Primary Site server?

            1. The tool can be run directly on the computer that hosts the distribution point, or remotely from another server.

      2. Thanks. Can this also be run to cleanup the ContentLibrary on de primary Site Server?
        Or is only for the Distribution Points?

      3. I tried running on SCCM 2012 Infra and getting below error message on Dp as well as Primary SCCM server.
        I am already part of Administrator on both the servers.

        Gathering information…
        Loading information from distribution point…
        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.
        at Microsoft.ConfigurationManager.ContentLibraryCleanup.CLContentLibrary..cto
        r(String remoteDPFqdn, String primarySiteServerFqdn, String primarySiteCode)
        at Microsoft.ConfigurationManager.ContentLibraryCleanup.Program.Main(String[]
        args)

  30. Avatar photo David Wolf says:

    Great preview of a useful tool. I’m curious, will the formatting of the bytes that will be deleted be fixed in the Current Branch version? 137,11,835 should be 13,711,835 bytes. Minor annoyance at most, though.

  31. So this tool is only in technical preview release now but is to be included in next the production release?

    I can see this tool freeing up a lot of diskspace for some of our customers distribution points.

  32. Avatar photo Emiliano Prosseda says:

    The tool crashes if any distribution is inprogress or failed state 🙁

    1. Thanks for that note. I had not tested the tool during content distribution. When you say tool crashes what exactly do you see ?.

      1. Avatar photo Emiliano Prosseda says:

        Hi Prajwal, actually the tools says that a package/program is not fully downloaded and stops working. The same happens when a package/program is in a failed state.

        1. Avatar photo Philippe Courtois says:

          Hi, thanks for the presentation, I agree with that point. If the package is not fully installed, the tool crash:System.InvalidOperationException: This content library cannot be cleaned up right now because package VAL01FC6 is not fully installed.

          1. thank you so much for reporting this issue. I will report this to Microsoft and I will see if this can be fixed in next version if so

            1. Hello!
              In the end of run tool I get this message: 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 distribution point. Package deletion has been disabled.
              How can I enable deletion?

              1. Are there any packages in distribution queue while you are running this tool ?.

                  1. I suggest you do not run this tool when there are packages in distribution queue.

Leave a Reply

Your email address will not be published. Required fields are marked *