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

The Following code write all the items from the list to CSV file.

$list.Items| foreach {
            $obj = New-Object PSObject -Property @{
                     "Title" = $_["Title"]
                     "Name" = $_["Name"]
                     "Modified Date" = $_["Modified"]
                     "Modified By" =$_["Modified By"]
                     "Size"= $_["File Size"]
                     "Path" = $web.Url + "/" + $_.File.Url

    }
    $exportlist += $obj
    $exportlist | Export-Csv -path $destinationfolder/'Folder.csv' -noType
    }

How to write only items contain in particular folder into CSV file. For example I have folder name Test inside my document library.folder contains many documents.i just want items which are inside Test into CSV file and not the whole list items.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Create SPQuery object and set its Folder property and then call GetItems on List and finally loop through the item collection.

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.Folder = $folder;
$items = $list.GetItems($spQuery);
share|improve this answer
    
Thanks Nadeem.learning lot from You –  Ashish Mar 10 at 9:40

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.