Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to add list items to a list by using powershell commands.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Yes - I'm not aware of a commandlet but it is easy to do using the Powershell commands agaist the object model. See PowerShell-SharePoint: Add a list item as an example (cross posted below for completeness). Just be aware that the site object still needs to be properly disposed as mentioned on the SharePoint Team Blog.

[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

$site    =     new-object Microsoft.SharePoint.SPSite("http://teams.contoso.com")                                                        
$web     =    $site.rootweb                                                                                                

$list    =    $web.Lists["Announcements"]                                                                              

$newitem=    $list.items.Add()                                                                                                  

$newitem["Title"]=    "New CFO Appointed";                                                                                          
$newitem["Body"]=    "Our new CFO is Harry Varden, money still not recovered from previous appointee, legal action is ongoing";                                                                                          
$newitem["Expires"]=     [DateTime]::Now.AddDays(5)

$newitem.update() 

$web.Dispose()
$site.Dispose()  
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.