Thursday, January 8, 2015

Add new Item to share point list using powershell


Here is a simple example to add new item to sharepoint list. Every time powershell script is executed it will add new item to the list  with pre populated Title as data and time.

SharePoint Environment 2007

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteurl="https://site url"
$listname="List name"
$site=new-object Microsoft.SharePoint.SPSite($siteurl);
$web=$site.openWeb();
$list = $web.Lists[$listname] ;
$item = $list.Items.Add();
$item["Title"] = get-date;
$item.Update();
$web.Dispose();
$site.Dispose();
write-host "Item added to list $listname"

No comments:

Post a Comment