Forum Discussion
How to find files over certain limit in SharePoint Library with hundreds of folders
I can now run the script, however, it's only showing me large folder sizes over 100Mb and not the individual files. It's also only going 2 folders deep (we have some folders that go 5-6 subfolders).
HI luvsql
Great that it is working
The following line is that one that will need to change
#Get All Files of the library with size > 100MB
$Files = Get-PnPListItem -List $List -PageSize 500 | Where {($_.FieldValues.FileLeafRef -like "*.*") -and ($_.FieldValues.SMTotalFileStreamSize/1MB -gt 100)}
The # means comment out this line i.e. it tells the programming language to ignore this row
So I suggest you change the script so it looks like this , removing the part after the -and statement
#Get All Files of the library with size > 100MB
#$Files = Get-PnPListItem -List $List -PageSize 500 | Where {($_.FieldValues.FileLeafRef -like "*.*") -and ($_.FieldValues.SMTotalFileStreamSize/1MB -gt 100)}
#Get all files, of any size
$Files = Get-PnPListItem -List $List -PageSize 500 | Where {($_.FieldValues.FileLeafRef -like "*.*")
I can't see anything in the script which will limit it to just 2 folders deep.
It may be that there are NO files larger than 100MB that exists in folders lower than 2 folders deep.
Microsoft have some training about PowerShell
as do a number of prominent SharePoint online authorities
https://www.google.co.nz/search?q=how+to+learn+powershell+for+sharepoint
Everyone who does our kind of work, can get value out of knowing something about PowerShell, so I highly recommend learning a little about it. I prefer dealing with people and the social anthropology side of my job, but there are times when Powershell makes things possible that wouldn't be otherwise.