PowerShell Calculated Column Create and Edit

How do you create a calculated column using PowerShell?  In my example, I’m creating a new field called Calculated Date Field, setting the formula, then setting the output type to DateTime.

How do I build the formula?  Go into your list, add a new calculated column, create your formula, test the formula.  If it works, copy the formula and delete the column.

$site = Get-SPweb "http://sharepointed.com/site/salsa/"


 $mList.Fields.Add("Calculated Date Field", "Calculated", 0)
 $SPField = $mList.Fields.GetField("Calculated Date Field")
 $SPField.Formula="=DATE(YEAR([Document Date])+7,MONTH([Document Date])+0,DAY([Document Date])+0)"


4 thoughts on “PowerShell Calculated Column Create and Edit

  1. i cant add the calculated column its saying “Property ‘Formula’ cannot be found on this object; make sure it exists and is settable”

  2. @ Poonam
    Did you replace “Document Date” with your own field? Try using one of the SharePoint default date fields (created or modified).

  3. Pingback: SharePoint list views filtered by date AND time « Thornton Technical

Leave a Reply

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