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.

1 Answer 1


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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