Copy SharePoint Online site pages from one site to another - Easy PowerShell Script

There are several PowerShell scripts and multiple ways OOTB and using third party to copy SharePoint Online Pages from one site to another. However, sometimes it might become a hectic job when you are limited to use OOTB available features only. 

I had to copy SharePoint Online site pages to another subsite, and here is the final script that I came up with.

You need to download and install SharePoint Online Management Shell from Microsoft web site and then run it as administrator. After that, copy below script (of course by updating the Source and Destination sites URL) in a notepad file, save it as .ps1 file and then just run this script.



  
$SourceSiteURL = "https://company.sharepoint.com/sites/ParentSite/ChildSite1"
$DestinationSiteURL = "https://company.sharepoint.com/sites/ParentSite/ChildSite2"
Connect-PnPOnline $SourceSiteURL -UseWebLogin $Files= Find-PnPFile -List "SitePages" -Match * foreach($file in $Files) { Connect-PnPOnline -Url $SourceSiteURL -UseWebLogin $pageName = $file.Name $TempFile = [System.IO.Path]::GetTempFileName() Export-PnPClientSidePage -Force -Identity $pageName -Out $TempFile Connect-PnPOnline -Url $DestinationSiteURL -UseWebLogin Apply-PnPProvisioningTemplate -Path $TempFile } Write-host "Pages copied Successfully!" -f Green


Simple, cheers....!

Happy SharePointing :)

Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

SharePoint online hub navigation not updating for other users