How to Add Calculated Column to SharePoint List using PowerShell?

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

PowerShell to add a calculated column in SharePoint list or library:

Here is how to add a calculated column to your SharePoint list using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables
$WebURL="https://projects.crescent.com"
$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 
$CalculatedCol.Formula='=TEXT(Created,"mmm-YYYY")'
$CalculatedCol.OutputType="Text"
$CalculatedCol.Update()
  
$web.Dispose() 

Script in action: Create calculated column in SharePoint 2013 using PowerShell

create calculated column in sharepoint 2013 using powershell

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “How to Add Calculated Column to SharePoint List using PowerShell?

  • Good work mate …

    Reply

Leave a Reply

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