Problem Area
[x] Page Transformation: Error during the use of page transformation from PnP PowerShell when using (Convert-PublishingPages.ps1)
Expected or Desired Behavior
When the transformation is run on site collection(Classic). I expect the page to be transferred over to the destination Modern Classic Site.
Observed Behavior
The pages from Source Pages library haven't transferred over to the destination pages. We got the following error
Get-PnPListItem : Could not find file 'PnP.Framework.resources'.
Steps to Reproduce
run the command: Convert-PublishingPages.ps1 with the source and target connections using (AD APP with Client ID and Certificate)
In the log we see the message: Log is empty
Get-PnPListItem : Could not find file 'PnP.Framework.resources'.
Notes
Changes have been done to the script like using ConvertTo-PnPPage instead of ConvertTo-PnPPage ConvertTo-PnPClientSidePage
PnpPowerShell versions:
PnP.PowerShell 1.3.0
PnP.PowerShell 1.2.14
PnP.PowerShell 1.2.0
If we run the following script with the same authentication method (AD APP with Client ID and Certificate) for converting only one page then the page transformed correctly.
Connect-PnPOnline -Url xxx -ClientId xxx -Tenant xxx.onmicrosoft.com -CertificatePath "C:\xxx.pfx" -CertificatePassword (ConvertTo-SecureString "xxxxxxx" -AsPlainText -Force)
ConvertTo-PnPClientSidePage -PublishingPage -Identity somepage.aspx -Overwrite -TargetWebUrl https://contoso.sharepoint.com/sites/targetsite -KeepPageCreationModificationInformation -PostAsNews -LogType File -LogVerbose -LogFolder c:\temp
With the following script, the error Message: ConvertTo-PnPPage : Could not find file 'PnP.Framework.resources'.
$sourceSiteUrl = "https://contoso.sharepoint.com/sites/sourceSite"
$targetSiteUrl = "https://contoso.sharepoint.com/sites/targetSite"
$sourceConnection = Connect-PnPOnline -Url $sourceSiteUrl -ClientId xxx -Tenant xxx.onmicrosoft.com -CertificatePath "C:\xxx.pfx" -CertificatePassword (ConvertTo-SecureString "xxxxxxx" -AsPlainText -Force)
$targetConnection = Connect-PnPOnline -Url $targetSiteUrl -ClientId xxx -Tenant xxx.onmicrosoft.com -CertificatePath "C:\xxx.pfx" -CertificatePassword (ConvertTo-SecureString "xxxxxxx" -AsPlainText -Force)
$web = Get-PnPWeb -Connection $sourceConnection
$pages = Get-PnPListItem -List Pages -Connection $targetConnection -PageSize 500
Foreach($page in $pages){
$targetFileName = $page.FieldValues["FileLeafRef"]
# If Welcome Page, then Rename,
# typical for flattening multiple sites that contain standard page(s) e.g. Welcome.aspx or Default.aspx
if($targetFileName -eq "Welcome.aspx"){
$targetFileName = "Welcome-$($web.Title.Replace(" ", "-")).aspx"
Write-Host " - Updating Welcome.aspx page to $($targetFileName)" -ForegroundColor Yellow
}
if($targetFileName -eq "Default.aspx"){
$targetFileName = "Default-$($web.Title.Replace(" ", "-")).aspx"
Write-Host " - Updating Default.aspx page to $($targetFileName)" -ForegroundColor Yellow
}
Write-Host " Modernizing $($targetFileName)..."
# Use the PageID value instead of the page name in the Identity parameter as that is more performant + it works when there are more than 5000 items in the list
$result = ConvertTo-PnPPage -Identity $page.FieldValues["ID"] `
-PublishingPage `
-TargetWebUrl $targetSiteUrl `
-PublishingTargetPageName $targetFileName `
-Connection (Connect-PnPOnline -Url $targetSiteUrl -ClientId 5fdb3165-5ea5-4161-a51c-507cde838e62 -Tenant atea.onmicrosoft.com -CertificatePath "C:\Projects\Intranet Modernization\PageTransformation\LV-GroupIT-Microsoft-Graph-API-SharePoint.pfx" -CertificatePassword (ConvertTo-SecureString "8865635c5aebcc8f0f240eb59cc6f56788fbf056966b0bfd5c72abdedbfce1de" -AsPlainText -Force))
-PageLayoutMapping "$($location)\$($MappingOutputFolder)\$($PageLayoutMappingFile)" `
-DontPublish `
-Overwrite `
-SkipItemLevelPermissionCopyToClientSidePage `
-LogSkipFlush `
-LogType File `
-CopyPageMetadata `
-LogFolder "$($location)\$($LogOutputFolder)"
}
About the "Could not find file 'PnP.Framework.resources'", seems as your PnP PowerShell installation is in an inconsistent state. Please clean all installed modules and install the latest (1.3) again:
Uninstall-Module -Name PnP.PowerShell -AllVersions -Force
Install-Module -Name PnP.PowerShell
Well, the key thing is that you can achieve what you need via calling ConvertTo-PnPPage...based upon above feedback that seems to be the case. What the Convert-PublishingPages.ps1 script does is loop over the pages in the source site and call ConvertTo-PnPPage...so to check things I would recommend the following:
Get-PnPListItem -List "Pages" -Connection $sourceConnection -PageSize 500 does list the pages you want to get converted. Note that if your site is localized the list might not be named Pages but something else.Hi @mohammadamer ,
Hope above got you unblocked, if so please close this issue or let me know so I can close it. If not please follow-up with more detailed error information.
Hi @jansenbe
Issue solved by
Uninstall-Module -Name PnP.PowerShell -AllVersions -Force
Install-Module -Name PnP.PowerShell