Change Content Type on SharePoint List with PowerShell

We encountered a problem with a content type on a document library. We were unable to modify the content type, change the column order or add/delete columns.

By removing and adding the content type again, the problem would be solved. However, you cannot remove a content type that is in use.

The following PowerShell code is able to replace the content type in a document library with another content type. It will remove the faulty content type from the list and add the content type again. This is done by adding a temporary content type based on the old one and setting the content type of all items (which are using the faulty content type) in the document library to the temporary content type. After the faulty content type is re-added all the items are set back to this content type and the temp content type will be removed.

If an item has another content type, this item will not be processed. If a library requires checking out items before editing, the script will check out the item. After the change is made, the script will perform a Check in and checks if an item needs approval, and of course approves the item.

All the script needs is url, list name, name of the old content type and the name of the new content type.

When no parameters are provided the script will ask for them before running.

If you want to replace the content type with the same one, then use as old and new CT name, the same name. It OldCT and NewCT are different the script will add the new one and replace the content type on the items with the new one. If content type doesn’t exist, the script will run into errors.

A transcript will be made and places in the Temp folder on the C-drive. The name of the transcript will contain a date and timestamp, so you’re able to run the script multiple time without overwriting the transcript log.