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

[玩转系统] SharePoint Online:使用 PowerShell 创建公告列表

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

SharePoint Online:使用 PowerShell 创建公告列表


要求:在 SharePoint Online 中创建“公告”列表。

如何在 SharePoint Online 中创建公告列表?

顾名思义,SharePoint Online 中的公告列表用于共享公告和新闻。它有“标题”和“正文”字段用于公告,还有“到期日期”来设置是否列出特定公告。在 SharePoint Online 中创建公告列表是一个简单的过程,只需几个简单的步骤即可完成。

以下是在 SharePoint Online 中创建公告列表的方法:

  1. 导航到 SharePoint Online 站点 >> 单击“设置齿轮”>> 选择“添加应用程序”。

    [玩转系统] SharePoint Online:使用 PowerShell 创建公告列表

  2. 在应用程序页面中,单击“公告”图块

    [玩转系统] SharePoint Online:使用 PowerShell 创建公告列表

  3. 为您的公告列表提供名称,然后单击“创建”。

    [玩转系统] SharePoint Online:使用 PowerShell 创建公告列表

这将在 SharePoint Online 中创建公告列表。公告列表通常添加到站点的主页上。创建公告列表后,您可以开始向列表添加公告。要添加公告,请单击列表左上角的“新项目”按钮,然后填写必要的字段,例如标题、正文和过期时间。

SharePoint Online:PowerShell 创建公告列表

公告列表用于共享新闻和公告消息。以下是用于在 SharePoint Online 中创建公告列表的 PowerShell CSOM 脚本。


#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"

#Set Parameter Values
$SiteURL="https://crescent.sharepoint.com"
$ListName="Townhall"

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

#Set creating data for announcement list
$CreationInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$CreationInfo.Title = $ListName
$CreationInfo.TemplateType = [int][Microsoft.SharePoint.Client.ListTemplateType]::Announcements
$CreationInfo.Description = "$ListName Announcements"

#Create Announcement in SharePoint Online
$List = $Ctx.web.Lists.Add($CreationInfo)
$Ctx.ExecuteQuery()

PnP PowerShell 创建公告列表

以下是在 SharePoint Online 中创建新公告列表的 PnP PowerShell 方法:


#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/purchase"
$ListName = "Announcements"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Create Announcement List
New-PnPList -Title $ListName -Template Announcements

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

取消回复欢迎 发表评论:

关灯