3

I want to copy items from one list to another using PowerShell, but what I would like to keep after copying data is versions or at least multiline of text column that has append feature.
I managed to do the copying part, but I succeeded to copy only active version of item. Bellow is my code

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$web = Get-SPWeb "siteURL"
$list1 = $web.Lists["OriginalList"]
$list2 = $web.Lists["NewList"]

$items = $list1.items | Where-Object {($_["Status"] -eq "Done"}
# here I count how many items will be copied from one list to another
$items.count;
foreach ($item in $items) {
    $newitem=$list2.items.Add()
    $newitem["column1"] = $item["column1"]
    $newitem["column2"] = $item["column2"]
    # here is multiline of text column that has append feature
    $newitem["column3"] = $item["column3"]
    $newitem.update()
}

$web.Dispose();

My question is, is there any chance of me copying all past comments from that column somehow? Or to copy all versions of item with PowerShell?

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.