I need to get all the documents name inside the folder from shared document using power shell.


2 Answers 2


Try this script

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0

$web = Get-SPWeb -Identity "weburl"

$rfolder=$web.Lists["Shared Documents"].RootFolder

Function GetFiles($folder)
   Write-Host "+"$folder.Name
   foreach($file in $folder.Files)
       Write-Host "`t" $file.Name

   # Use recursion to loop through all subfolders.
   foreach ($subFolder in $folder.SubFolders)
       Write-Host "`t" -NoNewline

You might also find some more usefull info at https://stackoverflow.com/questions/8024103/how-to-retrieve-a-recursive-directory-and-file-list-from-powershell-excluding-so

$web.Lists["Documents"].RootFolder.SubFolders["Your Folder Name"].Files
  • Thanks for the reply. But actually i want to get the files inside the folder from Shared Documents library in one of the site. I don't want to provide the folder name. It should find folder automatically.
    – Ishani
    Commented Feb 27, 2015 at 12:33
  • 1
    @Ishani, there can be plenty of folders inside the library. The script needs to know some kinda logic to get files from a particular folder. Commented Feb 27, 2015 at 13:35

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.