Copy Site Pages (ClientSidePage) Site to Site

%3CLINGO-SUB%20id%3D%22lingo-sub-135209%22%20slang%3D%22en-US%22%3ECopy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-135209%22%20slang%3D%22en-US%22%3E%3CP%3EOne%20of%20the%20items%20I've%20been%20trying%20to%20tackle%20is%20how%20to%20move%20a%20site%20page%20between%20site%20collections%20(two%20different%20communication%20sites).%26nbsp%3B%20In%20the%20same%20Site%20Pages%20library%2C%20this%20is%20simple.%26nbsp%3B%20The%20usage%20case%20scenario%20here%20would%20be%20if%20we%20have%20a%20designated%20%22UAT%22%20environment%20where%20users%20modify%20their%20site%20pages%20to%20their%20exact%20specifications.%26nbsp%3B%20Right%20now%20the%20only%20way%20I%20know%20of%20is%20to%20manually%20recreate%20this%20page%20in%20the%20destination%20site.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI've%20been%20working%20through%20the%20features%20of%20the%20Office%20DEV%20PnP%20PowerShell%20framework%20using%20the%20ClientSidePage%20objects%2C%20but%20it%20doesn't%20appear%20through%20development%20that%20this%20functionality%20is%20quite%20there%20to%20read%20a%20site%20page%2C%20then%20add%20a%20site%20page%20at%20a%20new%20target%20based%20on%20that.%26nbsp%3B%20Also%20tried%20varying%20other%20methods%20of%20moving%20files%20between%20sites%20to%20see%20if%20it%20would%20'magically'%20just%20work%20with%20no%20luck.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHas%20anyone%20ever%20tried%20or%20have%20come%20up%20with%20a%20solution%20similar%20to%20that%20in%20which%20I'm%20seeking%3F%3CBR%20%2F%3E%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFYI%3A%20Sharegate%20has%20been%20tried%20and%20also%20does%20not%20have%20that%20capability%20as%20they%20probably%20base%20their%20migrations%20on%20what's%20available%20to%20use%20already.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-135209%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-358774%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-358774%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20getting%20this%20error.%20Have%20someone%20resolved%20this%3F%3CBR%20%2F%3EGet-PnPFile%20%3A%20The%20WriteObject%20and%20WriteError%20methods%20cannot%20be%20called%20from%20outside%20the%20overrides%20of%20the%20BeginProcessing%2C%20ProcessRecord%2C%3CBR%20%2F%3Eand%20EndProcessing%20methods%2C%20and%20they%20can%20only%20be%20called%20from%20within%20the%20same%20thread.%20Validate%20that%20the%20cmdlet%20makes%20these%20calls%20correctly%2C%3CBR%20%2F%3Eor%20contact%20Microsoft%20Customer%20Support%20Services.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-304438%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-304438%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2457%22%20target%3D%22_blank%22%3E%40Alexander%20Tihme%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPnP%20worked%20for%20me%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EMy%20approach%20was%20simple.%20I%20downloaded%20the%20page%20as%20a%20file%20to%20my%20local%20machine%20using%3B%3C%2FP%3E%3CP%3EGet-PnPFile%20-Url%20'%2Fsites%2Fintranet%2FSitePages%2Fmyfile.aspx'%20-Path%20'C%3A%5CPages'%20-Filename%20'myfile.aspx'%20-AsFile%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20upload%20to%20the%20target%20site%20using%3B%3C%2FP%3E%3CP%3EAdd-PnPFile%20-Path%20'C%3A%5CPages%5Cmyfile.aspx'%20-Folder%20%22SitePages%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20will%20have%20to%20change%20some%20Webpart%26nbsp%3Bsettings%20after%20the%20file%20is%20uploaded.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20to%20PnP%20Team%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrabath%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-221887%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-221887%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F55975%22%20target%3D%22_blank%22%3E%40Jarrett%20Haynes%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F88473%22%20target%3D%22_blank%22%3E%40Mia%20Loh%C3%A9%20Chung%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edid%20you%20find%20a%20solution%20for%20this%20problem.%20I%20face%20the%20same%20issue%20at%20the%20moment.%20I've%20tried%20ShareGate%20(access%20denied%20with%20global%20admin%2C%20site%20coll%20admin%2C%20etc.)%20and%20looked%20at%20PnP%20and%20PowerShell%2C%20but%20there%20doesn't%20seem%20to%20be%20a%20way%20to%20copy%20or%20move%20a%20site%20page%20from%20the%20pages%20library%20to%20another%20site%20collection%20within%20the%20same%20tenant.%20The%20source%20site%20is%20a%20modern%20page%20of%20type%20communication%2C%20the%20target%20site%20is%20a%20modern%20page%20of%20type%20team%20site.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20any%20response.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlex%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-136061%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-136061%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Jarrett%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFull%20disclosure%2C%20I%20work%20for%20Sharegate%20%3A)%3C%2Fimg%3E%20The%20tool%20should%20be%20able%20to%20perform%20your%20action%20without%20any%20issues.%20Can%20you%20send%20an%20email%20to%20the%20support%20team%3F%20They'd%20love%20to%20take%20a%20look%20with%20you%20to%20identify%20the%20problem.%20Good%20luck!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-900693%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-900693%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20command%20you%20shared%20is%20to%20save%20page%20and%20upload%20it%20to%20same%20site%20collection%20under%20sitepages%20folder%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1092416%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1092416%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F85829%22%20target%3D%22_blank%22%3E%40Prabath%20Fonseka%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooks%20like%20a%20proper%20business%20process%20flow%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1488970%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488970%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F55975%22%20target%3D%22_blank%22%3E%40Jarrett%20Haynes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20had%20success%20using%20MS%20Power%20Automate%20(aka%20Flow).%3C%2FP%3E%3CP%3EI%20apologize%20if%20anyone%20thinks%20this%20is%20%22off%20topic%22%20but%20you%20can%20achieve%20this%20very%20simply%20using%20MS%20Power%20Automate%20AKA%20Flow%20(tested%206%2F25%2F20)%20and%20the%20SharePoint%20connector%20and%20Copy%20File%20action.%26nbsp%3B%3C%2FP%3E%3CP%3ECreate%20an%20instant%20flow%2C%20add%20the%20manually%20trigger%20a%20flow%20trigger%2C%20and%20add%20the%20SharePoint%20Copy%20File%20action.%20See%20the%20image%20below%2C%20you%20can%20choose%20the%20exact%20file%20you%20want%20to%20copy%2C%20and%20the%20destination%20folders%20in%20a%20separate%20site.%20I'm%20creating%20a%20more%20complex%20flow%20that%20uses%20a%20%22template%22%20site%20to%20copy%20the%20%22template%22%20pages%20after%20the%20fact%20when%20I%20create%20a%20new%20O365%20group%20(and%20associated%20site).%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SamMisemer_0-1593091634729.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F201007iC65590ACB6A4981F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22SamMisemer_0-1593091634729.png%22%20alt%3D%22SamMisemer_0-1593091634729.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EMy%20case%20is%20an%20educational%20environment%20and%20letting%20the%20content%20creators%20(teachers!)%20be%20able%20to%20make%20supplemental%20or%20main%20online%20courses%20WITHOUT%20having%20to%20be%20a%20sharepoint%20design%20whiz.%20I%20create%20the%20O365%20group%2C%20let%20the%20server%20make%20the%20site%20and%20team%2C%20then%20run%20my%20flow%20and%20copy%20the%20template%20pages%20to%20the%20new%20site%2C%20and%20the%20teachers%20can%20create%20a%20new%20course%20site%20based%20on%20existing%20approved%20branding%2Fstructure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHTH!%3C%2FP%3E%3CP%3E-SCM%3C%2FP%3E%3CP%3ESam%20Misemer%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1512724%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1512724%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F636843%22%20target%3D%22_blank%22%3E%40SamMisemer%3C%2FA%3E%26nbsp%3BTHANK%20YOU!%26nbsp%3B%20This%20was%20the%20most%20amazingly%20simple%20solution.%26nbsp%3B%20Definitely%20looking%20forward%20to%20using%20Automate%20more%20for%20tasks%20like%20this!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1513399%22%20slang%3D%22en-US%22%3ERe%3A%20Copy%20Site%20Pages%20(ClientSidePage)%20Site%20to%20Site%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1513399%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F724019%22%20target%3D%22_blank%22%3E%40vluke%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3A)%3C%2Fimg%3E%20Thank%20you!%20I%20am%20glad%20it%20helped.%20I%20went%20crazy%20trying%20to%20figure%20out%20how%20NOT%20to%20recreate%20the%20wheel%20each%20time%20I%20made%20a%20new%20course%20group%2Fsite%20and%20tried%20this%20and%20happily%20found%20my%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20now%20scripts%20to%20create%20some%20template%20sites%2C%20which%20basically%20run%20after%20the%20site%20creation%20and%20automate%20a%20lot%20of%20changes%2C%20but%20they're%20a%20lot%20more%20technically%20complicated.%20This%20is%20by%20far%20the%20easiest%20way%20I%20have%20found%20to%20do%20this.%20Take%20a%20look%20though%20at%20the%20scripts%20if%20you%20want%2C%20it%20might%20fit%20your%20solution%20better.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fsite-design-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fdeclarative-customization%2Fsite-design-overview%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFeel%20free%20to%20ping%20me%20if%20you%20need%20help%20in%20the%20future!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-SCM%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

One of the items I've been trying to tackle is how to move a site page between site collections (two different communication sites).  In the same Site Pages library, this is simple.  The usage case scenario here would be if we have a designated "UAT" environment where users modify their site pages to their exact specifications.  Right now the only way I know of is to manually recreate this page in the destination site.

 

I've been working through the features of the Office DEV PnP PowerShell framework using the ClientSidePage objects, but it doesn't appear through development that this functionality is quite there to read a site page, then add a site page at a new target based on that.  Also tried varying other methods of moving files between sites to see if it would 'magically' just work with no luck.

 

Has anyone ever tried or have come up with a solution similar to that in which I'm seeking?
 

FYI: Sharegate has been tried and also does not have that capability as they probably base their migrations on what's available to use already.

 

Thanks!

9 Replies
Highlighted

Hi Jarrett,

 

Full disclosure, I work for Sharegate :) The tool should be able to perform your action without any issues. Can you send an email to the support team? They'd love to take a look with you to identify the problem. Good luck!

Hi @Jarrett Haynes, @Mia Lohé Chung

 

did you find a solution for this problem. I face the same issue at the moment. I've tried ShareGate (access denied with global admin, site coll admin, etc.) and looked at PnP and PowerShell, but there doesn't seem to be a way to copy or move a site page from the pages library to another site collection within the same tenant. The source site is a modern page of type communication, the target site is a modern page of type team site.

 

Thank you for any response.

 

Alex

Highlighted

Hi @Alexander Tihme,

 

PnP worked for me :)

My approach was simple. I downloaded the page as a file to my local machine using;

Get-PnPFile -Url '/sites/intranet/SitePages/myfile.aspx' -Path 'C:\Pages' -Filename 'myfile.aspx' -AsFile

 

Then upload to the target site using;

Add-PnPFile -Path 'C:\Pages\myfile.aspx' -Folder "SitePages"

 

You will have to change some Webpart settings after the file is uploaded. 

 

Thanks to PnP Team

Cheers!

 

Prabath

Highlighted

I am getting this error. Have someone resolved this?
Get-PnPFile : The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord,
and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly,
or contact Microsoft Customer Support Services.

Highlighted

The command you shared is to save page and upload it to same site collection under sitepages folder?

Highlighted

@Prabath Fonseka 

Looks like a proper business process flow

Highlighted

@Jarrett Haynes 

I have had success using MS Power Automate (aka Flow).

I apologize if anyone thinks this is "off topic" but you can achieve this very simply using MS Power Automate AKA Flow (tested 6/25/20) and the SharePoint connector and Copy File action. 

Create an instant flow, add the manually trigger a flow trigger, and add the SharePoint Copy File action. See the image below, you can choose the exact file you want to copy, and the destination folders in a separate site. I'm creating a more complex flow that uses a "template" site to copy the "template" pages after the fact when I create a new O365 group (and associated site).

SamMisemer_0-1593091634729.png

My case is an educational environment and letting the content creators (teachers!) be able to make supplemental or main online courses WITHOUT having to be a sharepoint design whiz. I create the O365 group, let the server make the site and team, then run my flow and copy the template pages to the new site, and the teachers can create a new course site based on existing approved branding/structure.

 

HTH!

-SCM

Sam Misemer

Highlighted

@SamMisemer THANK YOU!  This was the most amazingly simple solution.  Definitely looking forward to using Automate more for tasks like this!

Highlighted

@vluke 

 

:) Thank you! I am glad it helped. I went crazy trying to figure out how NOT to recreate the wheel each time I made a new course group/site and tried this and happily found my solution.

 

There are now scripts to create some template sites, which basically run after the site creation and automate a lot of changes, but they're a lot more technically complicated. This is by far the easiest way I have found to do this. Take a look though at the scripts if you want, it might fit your solution better.

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-overview

 

Feel free to ping me if you need help in the future!

 

-SCM