Content Library Cleanup - System.NullReferenceException: Object reference not set to an instance of



Short Story

we use a single server to host everything MECM.  

Our content library has a heap of entries that are greyed out and the majority of the entries appear to be from 5+ years ago for deployments we no longer have.

How do I clean out all the invalid entries from content library explorer



the Details

  I tried running the tool contentlibrarycleanup.exe in whatif mode, but after running for about an hour, it ends with this


Analyzing local files, 100.00% complete...
Loading package data from provider...
Loading local package data...
Loading distributed packages from provider...
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)


our environment is server 2019, sql 2019, MECM 2002


I found this document -


it has this entry which is a bit vague, saying it will cleanup the DP but not if the DP is on a site server??


"The tool only affects the content on the distribution point that you specify when you run the tool. The tool can't remove content from the content library on the site server."


the way I read this is a little vague, but it suggests to me that maybe, if you have a single primary Site server that also contains your DP, this tool is not able to assist with cleaning up the DP of invalid content. Is that correct?


Is there another option for this scenario if the tool doesn't support a single DP on the site server?

How do I get rid of all the invalid entries in my content library explorer?


12 Replies

@PaulKlerkx I attached an example of what I am talking about re orphaned files, showing one being an old office deployment.  On this page;;  Jason Sandys states the following, but if they aren't orphaned, what are they?  

"It's not possible to have orphaned content in the site server's content library. Orphaned content happens in remote content libraries when content is not properly cleaned up because of one of a handful of reasons like connectivity loss."


this page - suggests they can only be 3 things

  • The package is the Configuration Manager client upgrade. This package includes "ccmsetup.exe". (DEFINITELY NOT THIS - that is there too but appears as "INVALID" and different to the ones with asterixis )

  • Your user account can't access the package, likely due to role-based administration. For instance, the Application Author role can't see driver packages in the console, so any driver packages on the distribution point are marked as disabled. (NOT THIS - I AM MECM AND SERVER FULL ADMIN and have been for over 10 years)

  • The package is orphaned on the distribution point.


@PaulKlerkx Even with the DP role co-located on the site server, you should still be able to run the Content Library Cleanup Tool against it. You may be hitting a bug here. I'd suggest raising a support request with Microsoft to make sure.

@Michiel Overweel @ I logged a case with Microsoft and the tech went straight to the document I mentioned above that says the cleaner tool doesn't work when co-located on the site server and said it wouldn't work.  He is escalating to see if we have any other options for cleaning out the orphaned entries.  

@PaulKlerkx I would disagree with that statement... I am able to run the tool against my co-located site server/distribution point content library just fine. As a matter of fact, when I tried last week, it successfully deleted about 6 GB worth of orphaned software update-related content. Having said that, I also have a couple of these disabled (greyed-out) packages in my library, just like you do, and these weren't deleted. However, I didn't run into the error that you experienced either. In my opinion, even though it might not fix your problem, you should be able to run the tool successfully nevertheless.

@Michiel Overweel just a quick update that I haven't given up on this, I'm still waiting for a MS tech to get back to me about my support call. no progress on this so far.  I'll post back here when that happens.  

@Michiel Overweel - MS called this afternoon while I was grabbing a drink so I missed it.  I did a bit of a read through the doco on contentlibrarycleanup and found there is an option for a log file.  initially I figured that would just return what is shown in the cmd window, however for me it came back with one line. 


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


I don't understand that, in what situation would I correctly have a package in the content library that isn't distributed to a DP.  


I also figured out that if I locate the package ID referenced in content library explorer for a greyed out app, then look that up in content status, that will give me the app name.  If I then go and delete that application, that will remove it from content status in the console, however the greyed out entry remains in content library explorer so now I have an entry in content library explorer for an application that doesn't exist anywhere in my console.  I did a count too, I have 152 greyed out entries in content library explorer.  

@PaulKlerkx Interested if you get an update on this as I'm running into the same exact issue.

@Nick-86 , I got this from MS yesterday, will post results back here when available -

"Please be informed I will update you within next couple of days with an appropriate details for the case."

@Nick-86 - one other thing I found was that if I attempt to export an application from the console, I get a similiar message

Object reference not set to an instance of an object."


I'm unsure if it is related, but being the same message, I'm now wondering if maybe there is a MECM dependency ( E.G. dotnet or WMI) that has a problem which is causing my issues.  

@PaulKlerkx Haven't tried to export an application but I can try that tomorrow when I log back in.


I'm currently trying to deal with an issue where my ADR for Windows 10 updates is creating thousands of content folders when it says there are only 433 updates. A lot of them look to be different languages so not sure if that's all it is but it's mind boggling. Need to get a handle on ADR best practices.

@Nick-86 your "issue" may actually be expected behaviour - - our Win10 ADR deployment package contains 49 items, SUG has 12 updates and our ADR content folder has 371 directories.