Getting files from a specific folder in a doc lib powershell

…this post was published on 2015 August 2.

$yourweb=”http://shp2013″
$yourlist=”Documents”
$yourfolder=”folder1″
$results = @()

$web = Get-SPWeb $yourweb
$my_list = $web.Lists | Where-Object { $_.Title -eq $yourlist}
foreach ( $item in $my_list.Items){
if ($item.File.ParentFolder.name -eq $yourfolder){
$results = $results+$item.Name
}
}
if ($results.length -gt 0){
“Files in folder:$yourfolder from list:$yourlist are”
$results
}
if ($results.length -eq 0){
“No files in folder:$yourfolder from list:$yourlist”
}

This entry was posted in Files, Powershell, Sharepoint. Bookmark the permalink.