How to Add New List Item in SharePoint using PowerShell?

My PowerShell scripts to add list item in SharePoint:

Add SharePoint list items using PowerShell
The syntax to add new list item in SharePoint using PowerShell, goes like this
#Get Web and List Objects
$Web = Get-SPWeb ""
$List = $Web.Lists["ListName"]

#Create a new item
$NewItem = $List.AddItem()
#Set Column values
$NewItem["ColumnName"] = "Field Value goes here!"
#Update the Item, so that it gets saved to the list

Add list item in SharePoint with PowerShell

Lets add new task to the task list using PowerShell: 
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Processing Variables

#Get Web and List Objects
$Web = Get-SPWeb $WebURL
$TaskList = $Web.Lists[$ListName]

#Create New Task Item
$NewTask = $TaskList.AddItem()
$NewTask["Title"] = "Migration Project - SOW"

#Add Date Time values
$NewTask["StartDate"] ="02/22/2015 00:00:00"
$NewTask["DueDate"] = "02/25/2015 02:00:00 PM"

#Add Assigned to People Picker field
$NewTask["AssignedTo"] = $Web.EnsureUser("Crescent\Salaudeen")


add sharepoint list items using powershell Here is my another article to create new list items in SharePoint ONline using PowerShell: Add Item to SharePoint Online List using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.