0

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

Thanks

2 Answers 2

2

Try this script

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0


$web = Get-SPWeb -Identity "weburl"


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

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
       GetFiles($Subfolder)
   }
 }

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

0
$web.Lists["Documents"].RootFolder.SubFolders["Your Folder Name"].Files
2
  • 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. 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.