当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:使用 PowerShell 将网站页面从一个网站复制到另一个网站

作者:精品下载站 日期:2024-12-14 15:53:33 浏览:14 分类:玩电脑

SharePoint Online:使用 PowerShell 将网站页面从一个网站复制到另一个网站


要求: 将网站页面复制到 SharePoint Online 中的另一个网站。

SharePoint Online:如何将页面复制到另一个网站集?

您是否需要将页面从一个 SharePoint Online 网站集复制到另一个网站集?也许您想要出于测试目的复制页面或在另一个网站集中创建类似的页面。本文将向您展示如何使用 PowerShell 在 SharePoint Online 中复制页面。

我们想要将新式页面从 SharePoint Online 中的一个网站复制到另一个网站。 “复制到”选项不支持将网站页面从一个网站复制到另一个网站。

[玩转系统] SharePoint Online:使用 PowerShell 将网站页面从一个网站复制到另一个网站

幸运的是,我们可以使用 PnP PowerShell 将现代页面复制到另一个站点:


#Parameters
$SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing"
$DestinationSiteURL = "https://crescent.sharepoint.com/sites/branding"
$PageName =  "About.aspx"

#Connect to Source Site
Connect-PnPOnline -Url $SourceSiteURL -Interactive

#Export the Source page
$TempFile = [System.IO.Path]::GetTempFileName()
Export-PnPPage -Force -Identity $PageName -Out $TempFile

#Import the page to the destination site
Connect-PnPOnline -Url $DestinationSiteURL -Interactive
Invoke-PnPSiteTemplate -Path $TempFile

此 PowerShell 脚本导出/导入给定页面及其所有 Web 部件、内容等。将所有页面从一个站点复制到另一个站点怎么样?

PowerShell 将所有网站页面复制到 SharePoint Online 中的另一个网站

要将所有页面复制到另一个网站集,请使用此 PowerShell 脚本。


#Parameters
$SourceSiteURL = "https://crescent.sharepoint.com/sites/marketing"
$DestinationSiteURL = "https://crescent.sharepoint.com/sites/branding"

#Connect to the Source Site
Connect-PnPOnline -Url $SourceSiteURL -Interactive

#Export all pages from the source
$TempFile = [System.IO.Path]::GetTempFileName()
Get-PnPSiteTemplate -Out $TempFile -Handlers PageContents -IncludeAllClientSidePages -Force

#Import the page to the destination site
Connect-PnPOnline -Url $DestinationSiteURL -Interactive
Invoke-PnPSiteTemplate -Path $TempFile

这会将“站点页面”库中的所有页面备份到包含页面中所有工件的 XML 文件,并将它们导入到给定的目标站点。我们可以使用此方法在 SharePoint Online 中的同一租户内或不同租户之间备份恢复网站页面。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯