Tuesday, March 19, 2013

Create new SharePoint List Item using SharePoint 2010 Management Shell (PowerShell)

Follow the steps to create new SharePoint List Item using SharePoint 2010 Management Shell (PowerShell):
1.       Open SharePoint 2010 Management Shell with Run as Administrator

2.       Modify and execute following script:

#Web absolute URL where list exists
$webURL = "<http://site:port/site/subsite>" 

#SPList Name where items to be added
$listName = "<List Name>" 

#Get the SPWeb object and save it to a variable
$web = Get-SPWeb $webURL 

#Get the SPList object to retrieve the List
$list = $web.Lists[$listName] 

#Create a new item
$newItem = $list.Items.Add() 

#Add properties to this list item
$newItem["Title"] = "Title Text"
$newItem["Description"] = "Description Text" 

#Update the object so it gets saved to the list
$newItem.Update()

$web.Dispose()

Contact Me for any technical help related with SharePoint 2010.

1 comment:

John said...

Worked for me...thanks