This script will simulate Sysinternal's DU.exe.  Disk Usage Analyser will list all directories below the one you specify, and summarize them, giving you the total size, the file count, and the sub-directory count for each sub-directory found.  It now includes a slight improvement, in that you can filter the results by file extension by setting the appropriate variable.

I find this works very well in identifying folders with multiple/big log files.

The program is divided logically into two parts:  The first part uses Get-ChildItem -Recurse, with a filter, to enumerate all the sub-directories.  The second part uses this list to do a non-recursive Get-Childitem on each folder, in order to calculate the total size, file count, and sub-directory count.  It has an optional filter, to report only on the file types you are interested in.

The results are stored in a variable called $results, and the code can be easily modified to export these results to a CSV file.

Please use the download link at the top of this page for the latest version.

PowerShell
Edit|Remove
# This script will give the total size, file count, and sub-folder count of each folder 
# found below a given directory.  It will display the results in tabular form. 
# This script can be easily modified to export the results to CSV. 
# Written by BigTeddy 24 September 2011 
# Last modified: 02 October 2012 
# Version 2.2 
 
$dirRoot = 'c:\scripts' # Change this as desired 
$filter = '*' # Change this as desired, e.g. *.log or *.txt 
 
function GetFolderSize($path){ 
    $total = (Get-ChildItem $path -ErrorAction SilentlyContinue -filter $filter | Measure-Object -Property length -Sum -ErrorAction SilentlyContinue).Sum 
    if (-not($total)) { $total = 0 } 
    $total 
    } # end function GetFolderSize 
 
# Entry point into script 
$results = @() 
$dirs = Get-ChildItem $dirRoot -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.psIsContainer} 
 
foreach ($dir in $dirs) { 
    
    $childFiles = @(Get-ChildItem $dir.pspath -ErrorAction SilentlyContinue -filter $filter| Where-Object{ -not($_.psIsContainer)}) 
    if ($childFiles) { $filecount = ($childFiles.count)} 
    else                     { $filecount = 0                  } 
 
    $childDirs = @(Get-ChildItem $dir.pspath -ErrorAction SilentlyContinue | Where-Object{ $_.psIsContainer}) 
    if ($childDirs ){ $dircount = ($childDirs.count)} 
    else                    { $dircount = 0                 } 
     
    $result = New-Object psobject -Property @{Folder = (Split-Path $dir.pspath -NoQualifier) 
                                              TotalSize = (GetFolderSize($dir.pspath)) 
                                              FileCount = $filecount; SubDirs = $dircount} 
    $results +$result 
    } # end foreach 
 
$results | Select-Object Folder, TotalSize , FileCount, SubDirs | Sort-Object TotalSize -Descending | Format-Table -auto 
Write-Host "Total of $($dirs.count) directories"