Cameron's Blog

PowerShell - Changing the Content Type of an Existing Page or Item

Before you change the content type of the item, be aware that you may lose data. Even if fields remain the same type it has been known to be reset when changing the content type, so please be careful to backup any crucial data.

Before changing the contenttype of your page, make sure that the content type you mean to change to is associated with the list or library. Otherwise you will get a generic error when loading your page.

You can do this simply by adding the SPContentType Object to the list holding the item:

$CType = $Site.RootWeb.ContentTypes[$ContentTypeName]

To actually change the content type of the item, you need to set the ContentTypeId Property of the item and update the item.

$Item["ContentTypeId"] = $CType.Id

Note that calling the property like this:

$Item.ContentTypeId = $CType.Id

will not work. PowerShell will complain that the property is read-only. Doing it the other way will work, though.