3

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.

1

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()
}
  • 1
    yes indeed this code is Powershell!!!! – Salvatore Di Fazio May 21 '13 at 7:24
  • Oh Yes Sorry :) I don't see a sign $ sorry :) – Grzegorz Z May 21 '13 at 7:52
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, privacy policy and cookie policy

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