SharePoint Online: Copy Site Pages from One Site to Another using PowerShell
Requirement: Copy site pages to another site in SharePoint Online.
SharePoint Online: How to Copy a Page to Another Site Collection?
We wanted to copy a modern page from one site to another site in SharePoint Online. The "Copy to" option doesn't support copying site pages from one site to another.
Luckily we've PnP PowerShell available to copy a modern page to another site:
PowerShell to Copy All Site Pages to Another Site in SharePoint Online
To copy all pages to another site collection, use this PowerShell script.
SharePoint Online: How to Copy a Page to Another Site Collection?
We wanted to copy a modern page from one site to another site in SharePoint Online. The "Copy to" option doesn't support copying site pages from one site to another.
Luckily we've PnP PowerShell available to copy a modern page to another site:
#Parameters $SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing" $DestinationSiteURL = "https://crescent.sharepoint.com/sites/branding" $PageName = "About.aspx" #Connect to Source Site Connect-PnPOnline -Url $SourceSiteURL -UseWebLogin #Export the Source page $TempFile = [System.IO.Path]::GetTempFileName() Export-PnPClientSidePage -Force -Identity $PageName -Out $TempFile #Import the page to destination site Connect-PnPOnline -Url $DestinationSiteURL -UseWebLogin Apply-PnPProvisioningTemplate -Path $TempFileThis PowerShell script export-imports a given page along with all its web parts, contents, etc. How about copying all pages from one site to another?
PowerShell to Copy All Site Pages to Another Site in SharePoint Online
To copy all pages to another site collection, use this PowerShell script.
#Parameters $SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing" $DestinationSiteURL = "https://crescent.sharepoint.com/sites/branding" #Connect to the Source Site Connect-PnPOnline -Url $SourceSiteURL -UseWebLogin #Export all pages from the source $TempFile = [System.IO.Path]::GetTempFileName() Get-PnPProvisioningTemplate -Out $TempFile -Handlers PageContents -IncludeAllClientSidePages -Force #Import the page to destination site Connect-PnPOnline -Url $DestinationSiteURL -UseWebLogin Apply-PnPProvisioningTemplate -Path $TempFileThis will backup all pages in "Site pages" library to a an XML file with all the artifacts from pages and import to given destination site. We can use this method to backup-restore site pages within same tenant or between different tenants in SharePoint Online.
Hi,
ReplyDeletethanks for your work.
Is it posible that I export sides by the last modification date?
E.g.: I would like to export all sides modified in the time between 21.12. - 27.12.
best regards
Raphael