SharePoint Online:使用 PowerShell 创建公告列表
要求:在 SharePoint Online 中创建“公告”列表。
如何在 SharePoint Online 中创建公告列表?
顾名思义,SharePoint Online 中的公告列表用于共享公告和新闻。它有“标题”和“正文”字段用于公告,还有“到期日期”来设置是否列出特定公告。在 SharePoint Online 中创建公告列表是一个简单的过程,只需几个简单的步骤即可完成。
以下是在 SharePoint Online 中创建公告列表的方法:
这将在 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\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\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


