Cleaning Up Content Types Orphaned from the Content Type Hub

One of my clients who doesn’t have a blog came up with a good fix the other day. Since he didn’t have a place to put it, he offered it to me to post.

Have you ever deleted a Content Type from the Content Type Hub which you had previously published – without unpublishing it first? If so, you probably have that Content Type sitting in all your Site Collections (now modern sites) and you can’t delete it because it came from the Content Type Hub.

Well, there’s a fix for that. The article I list in the Resources section below gets you there for on premises versions of SharePoint, but it says for SPO you should open a ticket with Microsoft support. (Comments about Microsoft support withheld.) No support ticket required.

If it’s a wholesale problem (lots of orphaned Content Types), then the script in the article will be helpful. After all, you need to figure out which Content Types are actually orphaned first. But if you know a specific single Content Type is an issue, you can simply recreate it using the original Name and Id.

Here’s an example, using PnP.PowerShell, of course! The important bit is line 5, where you recreate the Content Type which is orphaned. Obviously, you would use your own:

  • Tenant Name
  • Name
  • Id
  • Group
$cth = "https://sympmarc.sharepoint.com/sites/contentTypeHub"

Connect-PnPOnline -Url $cth -Interactive

Add-PnPContentType -Name "IT Template Document" -ContentTypeId "0x0101001611568CC163BF408A2B9341656A02290701" -Group "MyGroup" 

Once you’ve recreated the Content Type with the same name Name and Id, you can publish it and then unpublish it to get rid of the orphans.

The modern Content Type Gallery is a bit smarter. If you delete a Content Type from there, you’ll get this message, which basically says the Content Type – if published – will be unpublished before it is deleted. No more orphans! This is a good example why you should stop using the classic UI for the Content Type Hub.

Resources

How to Unpublish Orphaned Content Types in SharePoint, Script Provided (collabware.com) – Osama Khan

Similar Posts

One Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.