SharePoint 开发:如何将Classic Page 转换成Modern Page?
作者:互联网
Blog链接:https://blog.51cto.com/13969817
越来越多的企业希望将数据从legacy 的SharePoint平台迁移到SharePoint Online,因为这样用户可以使用Modern UI,访问数据时界面可以随着屏幕 size而自动调整页面布局,但最近跟韩国一个Partner讨论数据迁移后,Page UI无法convert成Modern UI的问题,如何向客户解释和排查原因?
客户源端环境是SharePoint 2013 Server,但Site Collection 的默认home page是default.aspx, 所以home page的URL类似: site collection URL/default.aspx, 与SharePoint 2013 Server新建的Site Collection home page URL不符。
排查问题:
· 我们使用SharePoint Designer访问了该Site Collection,发现default.aspx 存储在site的root folder中,而对比其他Site Collection, home page是存储在Site Pages library中。
· 查找了下相关资料,default page是使用在SharePoint 2003和SharePoint 2007的环境中,在SharePoint 2010时该种类型的page已经hidden了,新建Site Collection的default home page URL 类似:URL/SitePages/Home.aspx
解决方案:
如大家所掌握的,SharePoint Classic Page包含Wiki Pages, Web Part Pages, Blog Pages, Publishing Page, Web Page和Basic Page以及从低版本升级的default page:
· 目前无论是微软的Powershell还是.net客制化开发,仅支持Wiki Pages, Web Part Pages, Blog Pages, Publishing Page四种类型的Page从Classic Page转换为Modern Page;
· 其他Page,比如Default Page,我们可以在welcome page中将default page link替换为home page link,重新insert 相关的Web part。
下方是采用PowerShell convert pages的脚本示例,仅供参考:
<# .Synopsis Converts all classic wiki and web part pages in a site. You need to install PnP PowerShell: https://pnp.github.io/powershell/ Sample includes: - Conversion of wiki and web part pages - Connecting to MFA or supplying credentials - Includes Logging to File, log flushing into single log file .Example Convert-WikiAndWebPartPages.ps1 -SourceUrl "https://contoso.sharepoint.com/sites/classicteamsite" -TakeSourcePageName:$true .Notes Useful references: - https://aka.ms/sppnp-pagetransformation - https://aka.ms/sppnp-powershell #> [CmdletBinding()] param ( [Parameter(Mandatory = $true, HelpMessage = "Url of the site containing the pages to modernize")] [string]$SourceUrl, [Parameter(Mandatory = $false, HelpMessage = "Modern page takes source page name")] [bool]$TakeSourcePageName = $false, [Parameter(Mandatory = $false, HelpMessage = "Supply credentials for multiple runs/sites")] [PSCredential]$Credentials, [Parameter(Mandatory = $false, HelpMessage = "Specify log file location, defaults to the same folder as the script is in")] [string]$LogOutputFolder = $(Get-Location) ) begin { Write-Host "Connecting to " $SourceUrl if($Credentials) { Connect-PnPOnline -Url $SourceUrl -Credentials $Credentials Start-Sleep -s 3 } else { Connect-PnPOnline -Url $sourceUrl -Interactive Start-Sleep -s 3 } } process { Write-Host "Ensure the modern page feature is enabled..." -ForegroundColor Green Enable-PnPFeature -Identity "B6917CB1-93A0-4B97-A84D-7CF49975D4EC" -Scope Web -Force Write-Host "Modernizing wiki and web part pages..." -ForegroundColor Green # Get all the pages in the site pages library. # Use paging (-PageSize parameter) to ensure the query works when there are more than 5000 items in the list $pages = Get-PnPListItem -List sitepages -PageSize 500 Write-Host "Pages are fetched, let's start the modernization..." -ForegroundColor Green Foreach($page in $pages) { $pageName = $page.FieldValues["FileLeafRef"] if ($page.FieldValues["ClientSideApplicationId"] -eq "b6917cb1-93a0-4b97-a84d-7cf49975d4ec" ) { Write-Host "Page " $page.FieldValues["FileLeafRef"] " is modern, no need to modernize it again" -ForegroundColor Yellow } else { Write-Host "Processing page $($pageName)" -ForegroundColor Cyan # -TakeSourcePageName: # The old pages will be renamed to Previous_<pagename>.aspx. If you want to # keep the old page names as is then set the TakeSourcePageName to $false. # You then will see the new modern page be named Migrated_<pagename>.aspx # -Overwrite: # Overwrites the target page (needed if you run the modernization multiple times) # -LogVerbose: # Add this switch to enable verbose logging if you want more details logged # KeepPageCreationModificationInformation: # Give the newly created page the same page author/editor/created/modified information # as the original page. Remove this switch if you don't like that # -CopyPageMetadata: # Copies metadata of the original page to the created modern page. Remove this # switch if you don't want to copy the page metadata ConvertTo-PnPPage -Identity $page.FieldValues["ID"] ` -Overwrite ` -TakeSourcePageName:$TakeSourcePageName ` -LogType File ` -LogFolder $LogOutputFolder ` -LogSkipFlush ` -KeepPageCreationModificationInformation ` -CopyPageMetadata } } # Write the logs to the folder Write-Host "Writing the conversion log file..." -ForegroundColor Green Save-PnPPageConversionLog Write-Host "Wiki and web part page modernization complete! :)" -ForegroundColor Green } end { Disconnect-PnPOnline }
相关资料:
· Transform Classic Pages to Modern Pages
· Transforming to modern site pages using Powershell
谢谢大家阅读,将遇到的问题,整理分享出来,希望日后能帮助到大家。
标签:Modern,Classic,pages,SharePoint,Page,Write,Pages,page 来源: https://blog.51cto.com/u_13969817/2852036