0

Hi i have some list items in a custom list with custom columns, i want to copy these list items to another list in staging share point farm but only those list items to copy between date1 and date2 range. can i do copy paste option or powershell script will help me.

1 Answer 1

0

For getting items modified in a certain range, you can use a script like below. Remember to change the time.

$web = get-spweb yourSiteURL
$SPList = $web.lists["yourlist"]



$spqQuery = New-Object Microsoft.SharePoint.SPQuery
$spqQuery.ViewAttributes = "Scope = 'Recursive'"
$spqQuery.RowLimit = $SPList.ItemCount

$spqQuery.Query = '<Where>
      <And>
         <Gt>
            <FieldRef Name="Modified" />
            <Value Type="DateTime">2019-12-18T12:00:00Z</Value>
         </Gt>
         <Lt>
            <FieldRef Name="Modified" />
            <Value Type="DateTime">2019-12-24T12:00:00Z</Value>
         </Lt>
      </And>
   </Where>'

$SPListItems = $SPList.GetItems($spqQuery)

foreach ($splistitem in $splistitems) 
{
}

And you can add the copy and paste operations in side the for each. Make sure you are clear about all the columns concerned in this process.

Examples of copy and paste list items using Powershell: https://www.sharepointdiary.com/2015/10/copy-list-items-between-sharepoint-lists-using-powershell.html

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.