Microsoft 365 & Power
Platform Community
PnP Theme for DocFx

Modernizing classic pages from on-premises sites

Summary

This is a Modernizing classic pages from publishing sites example to show the conversion of an on-premises 2013 publishing page over to SharePoint Online modern sites - this includes the extraction of the mapping files and conversion process.

Example Screenshot

  • PnP PowerShell
  • PnP PowerShell V2

#-----------------------------
# Publishing Portal Commands
#-----------------------------

$sp13Conn = Connect-PnPOnline http://portal2013/en -Credentials OnPrem -ReturnConnection
$spOnlineConn = Connect-PnPOnline https://contoso.sharepoint.com/sites/PnPKatchup -Credentials Online -ReturnConnection

# Exporting Page Layout File
#------------------------------
# Example based on a page
Export-PnPClientSidePageMapping `
    -CustomPageLayoutMapping `
    -PublishingPage "Quality-Cherry-Cake.aspx" `
    -Folder "C:\temp\Demo" `
    -Connection $sp13Conn

# Example based to export all the layouts
Export-PnPClientSidePageMapping `
    -CustomPageLayoutMapping `
    -Folder "C:\temp\Demo" `
    -Connection $sp13Conn `
    -BuiltInWebPartMapping


# Transforming Page based on Exported Content
#-----------------------------------------------
ConvertTo-PnPClientSidePage -Identity "Quality-Cherry-Cake.aspx" -PublishingPage `
    -TargetConnection $spOnlineConn -Connection $sp13Conn `
    -Overwrite `
    -PageLayoutMapping C:\temp\Demo\custompagelayoutmapping-f3629db3-3e4d-48c4-b904-6fffab6dbb65-quality-cherry-cake.xml `
    -UserMappingFile C:\temp\Demo\usermapping.csv `
    -UrlMappingFile C:\temp\Demo\urlmapping.csv `
    -KeepPageCreationModificationInformation `
    -DisablePageComments `
    -LogType Console


Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell

Note

This script uses the older SharePoint PnP PowerShell Online module


#-----------------------------
# Publishing Portal Commands
#-----------------------------

$sp13Conn = Connect-PnPOnline http://portal2013/en -Credentials OnPrem -ReturnConnection -TransformationOnPrem
$spOnlineConn = Connect-PnPOnline https://contoso.sharepoint.com/sites/PnPKatchup -Interactive -ReturnConnection

# Exporting Page Layout File
#------------------------------
# Example based on a page
Export-PnPPageMapping `
    -CustomPageLayoutMapping `
    -PublishingPage "Quality-Cherry-Cake.aspx" `
    -Folder "C:\temp\Demo" `
    -Connection $sp13Conn

# Example based to export all the layouts
Export-PnPPageMapping `
    -CustomPageLayoutMapping `
    -Folder "C:\temp\Demo" `
    -Connection $sp13Conn `
    -BuiltInWebPartMapping


# Transforming Page based on Exported Content
#-----------------------------------------------
ConvertTo-PnPPage -Identity "Quality-Cherry-Cake.aspx" -PublishingPage `
    -TargetConnection $spOnlineConn -Connection $sp13Conn `
    -Overwrite `
    -PageLayoutMapping C:\temp\Demo\custompagelayoutmapping-f3629db3-3e4d-48c4-b904-6fffab6dbb65-quality-cherry-cake.xml `
    -UserMappingFile C:\temp\Demo\usermapping.csv `
    -UrlMappingFile C:\temp\Demo\urlmapping.csv `
    -KeepPageCreationModificationInformation `
    -DisablePageComments `
    -LogType Console


Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell

Note

This script uses:

  • the PnP.PowerShell module - tested with v1.9.0
  • requires PowerShell 7 to run

Contributors

Author(s)
Paul Bullock

Disclaimer

THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

Back to top Script Samples
Generated by DocFX with Custom Theme by PnP team