GitHub Icon Image
GitHub

Extract Modern Pages to Individual Provisioning Files

Summary

This script will extract each of the pages into a individual provisioning file allow you to either move selectively to another site or tenant. Note, this script does not include referenced files e.g. images, videos etc.

Example Screenshot

  • PnP PowerShell

[CmdletBinding()]
param (
    [Parameter(Mandatory = $true)]
    [string]$Url
)
begin{

    Write-Host "Connecting to " $Url

    Connect-PnPOnline -Url $Url -Interactive
}
process {

    Write-Host "Extracting pages..." $Url

    $pages = Get-PnPListItem -List "SitePages"

    $pages | Foreach-Object{

        $fileName = $_.FieldValues["FileLeafRef"]

        $pageName = $fileName.Replace(".aspx", "")

        Export-PnPPage -Identity $fileName -Out "$($pageName).xml"

    }

    Write-Host "Extracted all pages" -ForegroundColor Cyan
}

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

The way you login into PnP PowerShell has changed please read PnP Management Shell EntraID app is deleted : what should I do ?

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 Material UI