SharePoint Online: Create Announcement List using PowerShell

Requirement: Create Announcement List in SharePoint Online.

How to Create Announcement list in SharePoint Online?
As its name indicates, Announcements list in SharePoint Online is used to share announcements and news. It has "Title" and "Body" fields for announcement and also has "Expiration Date" to set whether a particular announcement to be listed or not. Here is how to create announcement list in SharePoint Online:
  • Navigate to the SharePoint Online Site >> Click on Settings Gear >> Select "Add an App" 
    sharepoint online announcement list
  • From the Apps page, Click on "Announcements" Tile
    sharepoint online powershell to create announcement list
  • Provide the name to your announcement list and click on Create.
    create announcement list in sharepoint online
This creates announcement list in SharePoint Online. Announcements lists are typically added to the home page of the sites.

SharePoint Online: PowerShell to Create Announcement List
Here is the PowerShell CSOM script to create 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()
SharePoint Online: Create Announcement List using PowerShell SharePoint Online: Create Announcement List using PowerShell Reviewed by Salaudeen Rajack on February 11, 2017 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.