On occasion, when managing files within SharePoint an administrator may be asked to report on how many files there are of a specific file type

The attached script will allow you to obtain a total count of files by extension within a Site Collection.  The script will also run through Folders and Document Sets.

How to Use

The script is easy enough to use.  Two lines need to be edited, after which the script can be run.  These are: -

  1. $siteURL = "http://<<YourSiteCollectionHere>>": Amend this line with your Site Collection URL
  2. if($item.Name.Contains(".gif")): Insert the extension noted in the brackets

Once the script has run, you will see a window similar to that below with a total count of your files.

Add-PSSnapin "Microsoft.SharePoint.PowerShell" 
$siteURL = "http://<<YourSiteCollectionHere>>"  
$site = Get-SPSite($siteURL)  
foreach($web in $site.AllWebs)  
    $listCounter = $web.Lists.Count  
    for($i=0;$i -le $listCounter;$i++)  
        $list = $web.Lists[$i]  
        if($list.BaseType -eq "DocumentLibrary") {  
        $newList = $web.Lists.item($list.ID); 
        Write-Host $newList 
        Write-Host "*********************" 
        foreach($item in $list.Items) 
            Write-Host $item.Name 
    Write-Host "-----------------------" 
Write-Host $count