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

[玩转系统] SharePoint Online:使用 PowerShell 创建 WIKI 页面

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

SharePoint Online:使用 PowerShell 创建 WIKI 页面


要求:使用 PowerShell 在 SharePoint Online 中创建 wiki 页面。

如何在 SharePoint Online 中创建 wiki 页面?

SharePoint Online 中的 Wiki 页面是可以使用基于浏览器的界面轻松创建和编辑的网页。它们旨在促进组织内的协作和知识共享。如果您想创建带有图像的文本内容,维基页面非常适合此目的。在 SharePoint Online 中使用 wiki 页面的主要优势之一是易于协作。多个用户可以同时编辑同一页面,并且更改会自动保存并进行版本控制。在 SharePoint Online 中创建 wiki 页面既快速又简单。

以下是在 SharePoint Online 中创建简单 wiki 页面的方法:

  1. 转到您的 SharePoint Online 网站 >> 单击设置齿轮,然后导航到“网站内容”页面
  2. 单击“新建>>”并在三个选项中选择“wiki 页面”选项。

    [玩转系统] SharePoint Online:使用 PowerShell 创建 WIKI 页面

  3. 输入您的 wiki 页面的名称,然后单击“创建”。

现在您的 wiki 页面已创建,您可以在页面上键入/复制粘贴任何内容,就像使用其他 wiki 页面编辑器一样。完成后,您可以保存页面。

SharePoint Online:使用 PowerShell CSOM 创建 WIKI 页面

要自动创建 wiki 页面,我们可以使用 PowerShell,如下所示:


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Config Variable
$SiteURL = "https://crescent.sharepoint.com/Sites/Marketing"
$PageRelativeURL="/sites/Marketing/Wiki/Knowledgebase.aspx"
$PageContent="A KEDB is a database of all such known errors, recorded as they are and when they happened - and they're maintained over time."

#Get Credentials to connect
$Cred= Get-Credential
 
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Create a Wiki page
$WikiPageInfo = New-Object Microsoft.SharePoint.Client.Utilities.WikiPageCreationInformation
$WikiPageInfo.WikiHtmlContent = $PageContent
$WikiPageInfo.ServerRelativeUrl = $PageRelativeURL
$WikiFile = [Microsoft.SharePoint.Client.Utilities.Utility]::CreateWikiPageInContextWeb($Ctx, $WikiPageInfo)
$Ctx.ExecuteQuery()

此 PowerShell 在给定 URL 中添加一个 wiki 页面。

使用 PnP PowerShell 在 SharePoint Online 中创建 wiki 页面

要使用 PnP PowerShell 在 SharePoint Online 网站中创建新的 wiki 页面,您可以使用 cmdlet Add-PnPWikiPage


#Config Variable
$SiteURL = "https://crescent.sharepoint.com/Sites/Marketing"
$PageRelativeURL="/sites/Marketing/Wiki/Knowledgebase.aspx"
$PageContent="A KEDB is a database of all such known errors, recorded as they are and when they happened - and they're maintained over time."

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Create a Wiki page
Add-PnPWikiPage -ServerRelativePageUrl $PageRelativeURL -Content $PageContent 

总之,Wiki 页面是 SharePoint Online 中协作和知识共享的强大工具。在 SharePoint Online 中创建 wiki 页面是一个简单的过程,可以使用 Web 浏览器界面或 PowerShell 来完成。通过使用 SharePoint Online PnP PowerShell 模块,您可以轻松地在 SharePoint Online 网站上创建 wiki 页面。无论您是记录流程、程序还是其他重要信息,Wiki 页面都是与您的团队协作和共享信息的好方法。

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

取消回复欢迎 发表评论:

关灯