This code snippet is for to Add Items to SharePoint List using Windows PowerShell Script.
- Add Microsoft.SharePoint.PowerShell
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
- Get the web object using Get-SPWeb siteURL.
$web = Get-SPWeb -Identity "http://siteURL.com/"
$list = $web.Lists["TestCustomList"]
- Greate object for Add Item
$newItem = $list.items.add()
- Put the values for each field
$newitem["Title"] = "Title_TEST"
- Do update Item to commit the changes.
$newitem.update()
Below code snippet show full code to add item to sharePoint list,
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
$web = Get-SPWeb -Identity "http://siteURL.com/"
$list = $web.Lists["TestCustomList"]
$newItem = $list.items.add()
$newitem["Title"] = "Title_TEST"
$newitem["Url"] = "/pages/help.aspx"
$newitem["Category"] = "Users"
$newitem["Priority"] = "3"
$newitem["Key"] = "Help"
$newitem["Open in New Window"] = "No"
$newitem.update()