ĐÀO TẠO DOANH NGHIỆP : SỞ KHOA HỌC CÔNG NGHỆ TỈNH ĐỒNG NAI

ENTERPRISE TRAINING: DONG NAI DEPARTMENT OF SCIENCE AND TECHNOLOGY.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

HÌNH ẢNH TẬP HUẤN LỚP SHAREPOINT WORKFLOW VÀ KIẾN TRÚC SHAREPOINT

PHOTOS OF SHAREPOINT WORKFLOW AND ARCHITECTURE CLASS.

Thursday, October 22, 2015

PowerShell copy list item to another list with same structure

Insert item from source list

$web = Get-SPWeb http://yourURL
$lista =$web.Lists["Source List Name"]
$listb =$web.Lists["Target List Name"]
$items = $lista.items
foreach ($item in $items) {
write-host -foregroundcolor yellow $item["Title"]
$newitem= $listb.items.Add()
$newitem["Title"] = $item["Title"]
$newitem["MultiLine"] = $item["MultiLine"]
$newitem["Number"] = $item["Number"]
$newitem["HyperLink"] = $item["HyperLink"]
$newitem["Choice"] = $item["Choice"]
$newitem["Created"] = $item["Created"]
$newitem["Author"] = $item["Author"]
$newitem["Modified"] = $item["Modified"]
$newitem["Editor"] = $item["Editor"]
$newitem.update()
start-sleep 1
}
$web.dispose
start-sleep 10

Powershell sharepoint get item by id

$web = Get-SPWeb http://yourURL
$lista =$web.Lists["Source List Name"]
$listb =$web.Lists["Target List Name"]
$items = $lista.GetItemById(523)
foreach ($item in $items) {
write-host -foregroundcolor yellow $item["ID"]
write-host -foregroundcolor yellow $item["Title"]
start-sleep 1
}
$web.dispose
start-sleep 10

Update Item by ID

$web = Get-SPWeb http://yourURL
$lista =$web.Lists["Source List Name"]
$listb =$web.Lists["Target List Name"]
$items = $lista.GetItemById(523)
foreach ($item in $items) {
write-host -foregroundcolor yellow $item["Title"]
$newitem= $listb.GetItemById(524)
$newitem["Title"] = $item["Title"]
$newitem["MultiLine"] = $item["MultiLine"]
$newitem["Number"] = $item["Number"]
$newitem["HyperLink"] = $item["HyperLink"]
$newitem["Choice"] = $item["Choice"]
$newitem["Created"] = $item["Created"]
$newitem["Author"] = $item["Author"]
$newitem["Modified"] = $item["Modified"]
$newitem["Editor"] = $item["Editor"]
$newitem.update()
start-sleep 1
}
$web.dispose
start-sleep 10

Thanks.