4

I have got two different lists. One is live updated by many users. The second list has the same fields and works as the master. I want to every day, at 6:00 o'clock a.m, merge List one with list two.

How could I add items from List one to list two? I want to do it by PowerShell and Timer Job.

2 Answers 2

2

Basically you have to create a new list (the merge list) the all the items from the two lists and add to the merge list:

$web = Get-SPWeb http://mysite
$list = $web.Lists["firstList"]
$merge = $web.Lists["mergeList"]
$items = $list.GetItems()

foreach ( $item in $item ) {
    # do job

    $newItem = $list.Items.Add() 
    $newItem["Title"] = $item["Title"]
    # others properties
    $newItem.Update()
}
3
  • 1
    yes indeed this code is Powershell!!!! May 21, 2013 at 7:24
  • Oh Yes Sorry :) I don't see a sign $ sorry :)
    – Grzegorz Z
    May 21, 2013 at 7:52
  • ($item in $items) ?
    – msanford
    Jul 21, 2020 at 14:53
1

Combine two lists like in the answer on SE here, or use a tutorial by Melick Rajee Baranasooriya from nothingbutsharepoint.com.

A tutorial on creating custom Timer Jobs can be found on MSDN.

Sharepoint list-synchronization with Powershell can be found on Jesper Christensen's blog.

Your Answer

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

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