When the page you want to transform lives in a folder then you can specify that folder (e.g. Use this -Library parameter when your wiki or web part page lives outside of the default SitePages library. In case of classic blog pages the first blog page where the title starts with the provided Identity will be used or alternatively you can also specify the id (integer value) of the page. pageA.aspx) for wiki, web part and publishing pages or the blog title for classic blog pages. Below table lists the command line parameters that you can use to control the page transformation via this cmdlet. The ConvertTo-PnPClientSidePage cmdlet is the key cmdlet to modernize a given page. Options for the ConvertTo-PnPClientSidePage cmdlet Write-Host "Wiki and web part page modernization complete! :)" -ForegroundColor Green Write-Host "Writing the conversion log file." -ForegroundColor Green KeepPageCreationModificationInformation ` TakeSourcePageName:$TakeSourcePageName ` # switch if you don't want to copy the page metadataĬonvertTo-PnPPage -Identity $page.FieldValues ` # Copies metadata of the original page to the created modern page. Remove this switch if you don't like that # Give the newly created page the same page author/editor/created/modified information # KeepPageCreationModificationInformation: # Add this switch to enable verbose logging if you want more details logged # Overwrites the target page (needed if you run the modernization multiple times) # You then will see the new modern page be named Migrated_.aspx # keep the old page names as is then set the TakeSourcePageName to $false.
# The old pages will be renamed to Previous_.aspx. Write-Host "Processing page $($pageName)" -ForegroundColor Cyan Write-Host "Page " $page.FieldValues " is modern, no need to modernize it again" -ForegroundColor Yellow
Write-Host "Pages are fetched, let's start the modernization." -ForegroundColor Green $pages = Get-PnPListItem -List sitepages -PageSize 500 # Use paging (-PageSize parameter) to ensure the query works when there are more than 5000 items in the list
# Get all the pages in the site pages library. Write-Host "Modernizing wiki and web part pages." -ForegroundColor Green Write-Host "Ensure the modern page feature is enabled." -ForegroundColor GreenĮnable-PnPFeature -Identity "B6917CB1-93A0-4B97-A84D-7CF49975D4EC" -Scope Web -Force $LogOutputFolder = $(Get-Location)Ĭonnect-PnPOnline -Url $SourceUrl -Credentials $CredentialsĬonnect-PnPOnline -Url $sourceUrl -Interactive for transforming publishing page, for transforming from on-premises SharePoint) available in our GitHub scripts location. There are additional sample scripts (e.g. It requires PnP PowerShell version 1.3.* (February 2021) or higher.
#MODERNIZED VERSION OF A CLASSIC FOLKTALE EXAMPLES HOW TO#
Below script shows how to transform pages.