2

I want to add a date based on item created date +2 years for all existing items in the New Column Date , can any one help on this using PowerShell?

Example:

Created date: 7/9/2015
Date:         7/9/2017

1 Answer 1

3

Here you go:

$spWeb = Get-SPWeb -Identity http://<sitecollection>/<subsite>
$lList=$spWeb.Lists["<ListName>"]  
$spItems = $lList.GetItems()
foreach($spItem in $spItems)
{
    $spItem["Date"] = $spItem["Created"].AddYears(2)
    $spItem.Update()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.