Michael Niehaus posted a nice script over on his blog for identify orphaned collections in ConfigMgr. 

Read his original post here.

This one goes back several years to when I was routinely writing code that used the ConfigMgr SDK (although in an odd coincidence, I was writing such code again yesterday).  It was pretty easy to run some buggy code that didn’t quite do what was intended, and as a result ConfigMgr might be left in an odd state.

One example of this: orphaned collections.  These exist in ConfigMgr, and if you look via WMI you can see them.  But they don’t exist in the console anywhere – they are invisible.  This would happen because those collections were not “rooted” to the top-level collection called “COLLROOT” (or any other collection, if you build collection hierarchies).

Other than “buggy code”, how else could these orphaned collections happen?  Good question, hard to say.

So how do you fix these?  Well, simple:  You “re-root” them by creating a new SMS_CollectToSubCollect WMI instance that says “this collection is a subcollection of COLLROOT”.  A long time ago, I wrote a script to do this.  After enough digging around, I found it again, so I’ll provide it here…..