Saturday, February 22, 2014

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

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...