SharePoint powershell to retrieve count of files in 2nd level subfolder in all subsites

Copper Contributor

Hi,
How to generate a report in csv to count of all files present in 2nd level subfolder [Change Requests] in all subsites  like

I have edited source from this link ... 

$lists = $web.lists | ?{$_.title -eq "Documents" -and $_.itemcount -ge "1" -And $_.BaseType -eq "DocumentLibrary"} #Change any identifier here
foreach($list in $lists)
{
Write-Host "- $($list.RootFolder.url)"
$DirpathList = $Dirpath +"\"+$list.title
CreateFolder($DirpathList)
#Download files in root folder
#$rootfolder = $web.GetFolder($list.RootFolder.Url)
#Download-SPContent($rootfolder)

#Download files in subfolders
foreach($folder in $list.folders)
{
#$folder = $web.GetFolder($folder.url)
if ($folder.name -eq "Change Requests")
{
$folder = $web.GetFolder($folder.url)
Download-SPContent($folder)
}
}
}

Thanks



0 Replies