SharePoint Online: Create Announcement List using PowerShell

Requirement: Create an “Announcements” List in SharePoint Online.

How to Create an Announcement list in SharePoint Online?

As its name indicates, the Announcements list in SharePoint Online is used to share announcements and news. It has “Title” and “Body” fields for announcements and also has “Expiration Date” to set whether a particular announcement is to be listed or not. Creating an announcement list in SharePoint Online is a simple process that can be done in a few easy steps.

Here is how to create an announcement list in SharePoint Online:

  1. Navigate to the SharePoint Online Site >> Click on Settings Gear >> Select “Add an App”.
    sharepoint online announcement list
  2. From the Apps page, Click on “Announcements” Tile
    sharepoint online powershell to create announcement list
  3. Provide the name to your announcement list and click on Create.
    create announcement list in sharepoint online

This creates an announcement list in SharePoint Online. Announcement lists are typically added to the home page of the sites. After creating the announcement list, you can start adding announcements to the list. To add an announcement, click on the “New Item” button in the top-left corner of the list and fill in the necessary fields, such as Title, Body, and Expires.

SharePoint Online: PowerShell to Create Announcement List

Announcements lists are used to share news and announcements messages. Here is the PowerShell CSOM script to create an announcement list in SharePoint Online.

#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 to Create Announcement List

Here is the PnP PowerShell way to create a new announcements list in SharePoint Online:

#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

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. Passionate about sharing the deep technical knowledge and experience to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *