Forum Discussion
Thao Pham-Aaltonen
Sep 19, 2018Brass Contributor
Copy or Move Site Page from one site to another
Hello, I've been searching to see if this is possible but it appears with the modern experience, you can only copy a site page to the same Site Pages library in the same site. If I switch my view to...
deanshepherd
Sep 20, 2024Brass Contributor
I have allways used this simple powershell to move\copy pages between sites. Wish the copy to button would allow you to move pages across sites that you are an owner of simalar to documents ... sey lah vee, maybe next year
#Parameters, set the source site, set the destination site set the page name
$SourceSiteURL = "https://tenant.sharepoint.com/sites/mysourcesite"
$DestinationSiteURL = "https://tenant.sharepoint.com/sites/mydestinationsite"
$PageName = "mypage.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
#Parameters, set the source site, set the destination site set the page name
$SourceSiteURL = "https://tenant.sharepoint.com/sites/mysourcesite"
$DestinationSiteURL = "https://tenant.sharepoint.com/sites/mydestinationsite"
$PageName = "mypage.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
henriqueserafim
Sep 20, 2024Copper Contributor
That is another approach yes and it does the job. The idea of this extension is to allow a worries free about having to change/adapt the code for different tenants, pages, sites,webs. You can do it using powershell, power automate, old/legacy sharepoint features or using the extension. Just another option to be added with pros and cons obviously. But nice and cute little piece of code you have there 😉