question

SPSteve-6194 avatar image
0 Votes"
SPSteve-6194 asked SPSteve-6194 commented

Invoke-PnPSiteTemplate Changes Page Links

To move pages from one site to another (SharePoint Online, modern), I use the PnP PowerShell commands below:

Source site:    

 Export-PnPPage -Identity $pageName -Force -Out $tempFile

Destination Site:

 Invoke-PnPSiteTemplate -Path $tempFile

The problem is, once the page is on the destination site, all the links have been changed so they point to the destination site. I understand that this is typically desirable, but in this case I need to them to stay constant. Does anyone know of a way to do this?

I have been looking for other commands to maybe get the text of the page, have PowerShell find and replace the links back to the original, and then write the text back, but I don't think that's possible with PnP PowerShell.

Any help would be appreciated.

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SPSteve-6194 avatar image
1 Vote"
SPSteve-6194 answered SPSteve-6194 edited

I was able to solve this.

I didn't notice at first that the URL for each link started with "{site}". After the export command executed, I opened up the temp file with Notepad and did a find-and-replace, replacing "{site}" with the full URL of the source site (https://company.sharepoint.com/sites/sitename). I then executed the second command to create the page on the destination site. All links now pointed to the source site.

It's worth noting that, in the export file, each link is listed twice: the first is the actual link while the second is what shows up when you hover over the link. Example:
a href="{site}/SitePages/sitepage.aspx" data-cke-saved-href="https://#company#.sharepoint.com/sites/#site#/SitePages/sitepage.aspx"

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ElsieLu-MSFT avatar image
0 Votes"
ElsieLu-MSFT answered SPSteve-6194 commented

Hi anonymous user ,

You could try to use Microsoft Flow to move modern pages between sites:
124937-68.jpg

Please refer to this thread for more information:
Copy or Move Site Page from one site to another


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


68.jpg (19.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, @ElsieLu-MSFT. I didn't get a chance to try out your suggestion. I wasn't sure how to trigger an existing file. I didn't want it to trigger if someone else created a page.

0 Votes 0 ·