How to Add Calculated Column to SharePoint List using PowerShell?

Requirement: Add new Calculated field to SharePoint list programmatically using PowerShell script.

PowerShell to add calculated column in SharePoint list or library:
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

$ListName="Proposal Documents"
$CalculatedColumnName="Created Month-Year"

#Get the Web
$web = Get-SPWeb $WebURL
#Get the List
$list = $web.Lists.TryGetList($ListName)
#Add new calculated column
$list.Fields.Add($CalculatedColumnName, "Calculated", $false)

#Get the column
$CalculatedCol = $List.Fields.GetField($CalculatedColumnName)
#Set Formula for calculated column 

Script in action: Create calculated column in SharePoint 2013 using PowerShell
create calculated column in sharepoint 2013 using powershell

1 comment:

Please Login and comment to get your questions answered!

Powered by Blogger.