Share via


Add listitems using PowerShell

$weburl = "https://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()

Comments

  • Anonymous
    January 22, 2015
    Thanks
  • Anonymous
    August 26, 2015
    simple and clear thanks a lot
  • Anonymous
    August 27, 2015
    Much better :
    $web = Get-SPWeb -Identity $webUrl
    $list = $web.Lists[$listname]
    $newItem = $list.AddItem()
    $newitem["Title"] = $a
    $newitem["Custom_Column1"] = $b
    $newitem["Custom_Column2"] = $c
    $newitem.update()
  • Anonymous
    August 27, 2015
    Much better :
    $web = Get-SPWeb -Identity $webUrl
    $list = $web.Lists[$listname]
    $newItem = $list.AddItem()
    $newitem["Title"] = $a
    $newitem["Custom_Column1"] = $b
    $newitem["Custom_Column2"] = $c
    $newitem.update()