Creating a Duplicate Page in different Site Collection

Iron Contributor

Having watched the PnP video Programmatically creating and updating modern pages in SharePoint Online by @Bert Jansen and @VesaJuvonen, I saw that it was possible to create a new page and to set its contents using the CanvasContent1 property of the new page. I would like to create a duplicate of a page in a second site pages library in a different site collection, so that it has all the same sections, web parts and content of the original.

 

I would like to do this with PnP PowerShell, but I notice in the documentation for the Set-PnPClientSidePage cmdlet that this is not one of the properties that is available to set via a parameter to the cmdlet.  How can I access this property in both the source and target pages? I would like to do something like:

 

Page2.properties["CanvasContent1"] = Page1.properties["CanvasContent1"]

 

Is there any way this is possible?

 

Thanks

3 Replies
It's not quite that easy to do :P. You basically have to hand craft out and script each element of the page from the list content to everything else. So if you're only doing this for one site collection your probably better off just manually building out the page to match.

The site scripting is mainly for site templates and deploying custom solutions and pages etc.

>>You basically have to hand craft out and script each element of the page<<

 

Okay, but why is that the case?  The video I referenced goes out of its way to say that "this is the content of the page". It's shown to be a string. Not sure why moving the contents of one property to another is an issue, especially if they are the same type .

 

>>if you're only doing this for one site collection your probably better off just manually building out the page<<

 

Sorry but this is EXACTLY the scenario we are trying to *avoid.* It needs to be done in TWO site collections where the pages will be saved as drafts and then manually translated into different languages on site in those countries. They should only have to change the text to the correct language and then hit Publish, not have to completely rebuild the page each time there's a relevant piece of news in that country.

 

Basically, the localization story for news in "modern" is very incomplete and I am desperately trying to come up with some kind of work around that will convince a paying customer that going the Microsoft-recommended route is worth doing.

 

>>The site scripting is mainly for site templates and deploying custom solutions and pages <<

 

Sure, but that's not really relevant -- people have been re-purposing things forever.  Cars are for getting people from one place to another,  but some people race them, some people live in them and some people use them to create works of art. 

 

So failing the simple property update, is there at least some way to open up the existing page and cycle through it's structure so it can be duplicated in an automated loop, without having to be structured by hand? Like Psuedo code:

 

obj = pageonecontent

obj2 = newpage()

foreach $element in obj

   obj2.add-element($element)

next

 

Thanks

<<BUMP>>

So what is the current story on Modern News pages that need to be in multiple languages?

 

When my customer creates a news page in English, I need that page to be copied with all of its contents to 2 other sites (each one set up with a different default language), where authors can change/translate the title and text and then publish. They should not have to "rebuild the page."

 

How can this be accomplished in the new "modern" architecture?  Flow will not let me just "copy the page" to the Site Pages library of the other language sites.

 

Thanks.