Find larger files inside web application in SharePoint using PowerShell


Recently I was reading one article where I got to know how to find list of larger files in SharePoint using PowerShell. It explained how to find out files larger than 50MB through PowerShell.

Also check out:
Creating App Parts using visual studio 2013


Delete list using SharePoint 2010 client object model

SharePoint 2013: How to show User Presence on mouse hover

Below is the PowerShell script:

cls
if((Get-PSSnapin | Where {$_.Name -eq “Microsoft.SharePoint.PowerShell”}) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
Start-SPAssignment -Global
#Change the site url below
$Site = Get-SPSite http://SiteURL/
$spWeb = $Site.WebApplication
#Enter the target file size in MB
$fileSize = 50
[string]$fileUrl
Write-Host “——Checking the SP web app for large files——”
# Enumerate though all site collections, sites, sub sites and document libraries in a SP web app
if($spWeb -ne $null)
{
foreach ($siteColl in $spWeb.Sites)
{
foreach($subWeb in $siteColl.AllWebs)
{
foreach($List in $subWeb.Lists)
{
if($List.BaseType -eq “DocumentLibrary”)
{
$ItemsColl = $List.Items
foreach ($item in $ItemsColl)
{
$itemSize = (($item.File.Length)/1024)/1024
if($itemSize -Ge $fileSize)
{
$itemUrl = $item.Web.Url + “/” + $item.Url;
Write-Host $itemUrl “, File size:: ” $(‘{0:N2}’ -f $itemSize) MB -ForegroundColor Green
}
}
}
}
}
}
}
Write-Host “———DONE———”
Stop-SPAssignment -Global

Check out Best Alternative to InfoPath -> Try Now

EnjoySharePoint YouTube Channel

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →