When working with the SharePoint Content Type Hub and published Content Types in general, one mistake a lot of experienced users and administrators make is deleting published Content Types from the Content Type Hub before unpublishing them first. This can result in the Content Type becoming a published orphaned Content Type, which continues to show up in new site collections or sites requesting a refresh of all published Content Types.
I’ll go over some of the basics before walking you through the process of unpublishing published orphaned Content Types. This post will cover:
Definitions for all published Content Types are stored in the term store database (Managed Metadata Service database) and all sites subscribing to the Content Type Hub pull the definitions from the term store database rather than from the Content Type Hub.
Unpublishing the content type is very similar to publishing it and involves following steps:
If you forget to unpublish a Content Type before you delete it from the Content Type Hub, SharePoint will not warn you about it and that Content Type definition will still exist in the term store database as a published Content Type.
During my projects, I have run into two types of problems resulting from published orphaned Content Types:
The second issue happens frequently in upgrade and migration scenarios where a content migration tool (like ShareGate) is utilized. These tools can bring over content and recreate the Content Types, but with incorrect parent Content Types (i.e., instead of the CLM Document, they may set the parent to Document) which breaks the connection to the published Content Type.
However, in some instances the issue arises when someone deletes a published Content Type without unpublishing it first, and then recreates another Content Type with the exact same name. The newly created Content Type has the same name but a different ID in the term store database and is treated as a separate object/content type. When the Content Types are published, the orphaned Content Type will be added to site collections first, and when the second Content Type is added (with the same name) it will run into a name conflict and fail to publish to the site. Instead, you will get an error logged in the Content Type publishing log on the site collection.
Unfortunately, there is no way to unpublish a published orphaned Content Type in the SharePoint interface. Furthermore, you should never alter SharePoint databases directly, so you cannot unpublish them directly in the term store database.
After searching on this issue for a while, I have come across a PowerShell based approach and script provided by Microsoft’s Stefan Gossner. It seems you can issue a supported unpublish command to SharePoint for the Content Type definitions stored in the term store database using PowerShell. The script identifies orphaned Content Types by comparing names of all published Content Types in a target/sample site collection and the Content Type Hub. It also issues the unpublish call to all published Content Types that are found in the target site collection but are missing from the Content Type Hub.
While this is a great solution, there is a minor problem in the script’s approach which is specific to the second problem scenario I previously mentioned, where a user may have deleted published Content Type without unpublishing it, creating a new Content Type with the exact same name. The script’s logic will do a comparison and find a Content Type with same name in both sites (target site and Content Type Hub) even though the Content Type IDs will be different. This can easily be remedied by changing the comparison in the script from name to the ID of the Content Types.
Attached to this post, you will find a slightly updated script that you can use to unpublish orphaned Content Types. I should caution you that I have used this script before in several test and production environments without any issues, but the script is being provided as-is without any expressed or implied warranties. Please use it at your own risk.
If you suspect there are orphaned Content Types in your SharePoint environment, you can run this script to verify that.
If you run the script without the unpublish switch, it will not make any changes to the environment and will only report on the published orphaned Content Types that it discovers.
Please follow these steps to run a comparison and unpublish orphaned Content Types:
In SharePoint Online, you do not have access to the timer jobs or the back end so there is no way (that I am aware of) to be able to issue the unpublish command. You should be extra careful and remind all users that have access to the Content Type Hub to always unpublish Content Types before deleting them.
If you still find yourself in the situation where you have published orphaned Content Types, then reach out to Microsoft support and they should be able to unpublish those for you.
Update: Microsoft has since rolled out the modern interface for Content Type Gallery which is available on the Content Type Hub and the SharePoint Admin center in Office 365. In this modern interface, when you delete a published content type, you are shown a warning message that confirms that the content type will be unpublished before being deleted. Going forward, you should not run into the orphaned published content type situation described above in SharePoint Online.
Thanks for reading our article about unpublishing orphaned Content Types! Want to learn more? We've got an article about how to create SharePoint Content Types, and an advanced discussion on Content Types.
Our team is happy to assist with your information management in M365 needs, so contact us with your questions or check out our free chart covering the capabilities of M365 and our data lake, Collabspace, below: