Home > powershell > Is it possible to use powershell to change the content type of a page layout after its been uploaded to a masterpage gallery?

Is it possible to use powershell to change the content type of a page layout after its been uploaded to a masterpage gallery?

June 1Hits:1
Advertisement

Im trying to automate as much of the upgrade I am working on and one of the manual steps is to change the page layout of 5 root webs of site collections, each of which has to have this new page layout uploaded to it as well as the content type changed.

I have script to upload the page layout, and change the page layout of the page, but not change the content type of the layout.

Is the content type an exposed property of the page layout? If so, how would I access it?

Answers

Here is a different looking approach since it has used Module.File.Property and Elements.xml to update the pages: http://blog.mastykarz.nl/provisioning-publishing-pages-powershell/

You can update the associated content type by this indirect route. Suppose you have a content type name $contentTypeName, a web $web, and the list item of your page layout, $item.

$item.Properties["PublishingAssociatedContentType"] = ";#" + $contentTypeName + ";#" + $web.AvailableContentTypes[$contentTypeName].Id.ToString() + ";#"
$item.Update()
$item.File.CheckIn("system update")
$item.File.Approve("system update")

Source: Rob Garrett's blog

Related Articles

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.925 s.