Tuesday, May 14, 2013

Add listitems with PowerShell

$weburl = "http://mysharepoint"
$listname = "TestList"
$a = "Text1"
$b = "Text2"
$c = "Text3"



Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue 
$web = Get-SPWeb -Identity $webUrl
$list = $web.Lists[$listname]
$newItem = $list.items.add()
$newitem["Title"] = $a
$newitem["Custom_Column1"] = $b
$newitem["Custom_Column2"] = $c

$newitem.update()

1 comment: