SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to PowerShell and would like to achieve the following tasks on a SharePoint 2010 Document library:

1) Using PowerShell, how can I display the List of Documents in a simple Document Library.

2) While traversing through the documents list, how can I modify the value of a custom added column in the Document Library?

share|improve this question
up vote 5 down vote accepted

Here's a simple example of how to display and update the 'title' field that could be modified slightly to achieve this:


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

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

foreach ($listItem in $list.Items)
    #display the filename of the document
    write-host $listItem.Name

    #update the title field to the filename
    $listItem["Title"] = $listItem["Name"]

share|improve this answer
This is great. It worked on my SPS2010. I require some more inputs further: 1) Can you clarify if this is the old method which can be applied on MOSS 2007 list too? 2) Will the above script run from a Client workstation 3) Are there any better ways to achieve this using SharePoint 2010 PowerShell CommandLets? – kamleshrao Jun 10 '10 at 4:42
1) yes the method above should work on both SharePoint 2007 and 2010 as this part of the server object model (OM) hasn't changed. 2) To run scripts remotely you will need to use PowerShell remoting. 3) yep there are other neater ways to do this using the SharePoint 2010 Powershell Snapin - check out… for some tips – Ari Bakker Jun 10 '10 at 9:30
Can you please send the complete URL of dmirtysotnikov – kamleshrao Jun 10 '10 at 11:25

Your Answer


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.