OK, so out the box, SharePoint online does not offer us any possibility to copy site pages from site collection A to site collection B.
What are the alternatives:
1. Power Automate
2. PnP PowerShell
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#Parameters $SourceSiteURL = "https://arachita1.sharepoint.com/sites/18NOV2023-SOURCE/" $DestinationSiteURL = "https://arachita1.sharepoint.com/sites/18NOV2023-Destination/ " #Connect to the Source Site Connect-PnPOnline -Url $SourceSiteURL -Interactive #Export all pages from the source $TempFile = [System.IO.Path]::GetTempFileName() Get-PnPSiteTemplate -Out $TempFile -Handlers PageContents -IncludeAllClientSidePages -Force #Import the page to the destination site Connect-PnPOnline -Url $DestinationSiteURL -Interactive Invoke-PnPSiteTemplate -Path $TempFile |
or for a single file:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#Parameters $SourceSiteURL = https://arachita1.sharepoint.com/sites/SourceSite1 $DestinationSiteURL = https://arachita1.sharepoint.com/sites/DestinationSite1 $PageName = "Ariane2.aspx" #Connect to Source Site Connect-PnPOnline -Url $SourceSiteURL -Interactive #Export the Source page $TempFile = [System.IO.Path]::GetTempFileName() Export-PnPPage -Force -Identity $PageName -Out $TempFile #Import the page to the destination site Connect-PnPOnline -Url $DestinationSiteURL -Interactive Invoke-PnPSiteTemplate -Path $TempFile |
Enjoy!
