Disk Usage Analyser

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, folder count, and the file count for each sub-directory found. You can filter on file type for reports.

du.ps1
 
 
 
 
 
3 Star
(5)
3,975 times
Add to favorites
Storage
10/2/2012
E-mail Twitter del.icio.us Digg Facebook
  • Can this be run on a list of remote computers
    1 Posts | Last post August 19, 2015
    • The script is a big help.
      
      Is there a way you can run this on a list of remote computers?
  • Version of PwerShell Needed
    1 Posts | Last post March 11, 2014
    • Will this script run on POwershell 1.0? We have a Server 2008 with SP1.
      
      Thanks
  • Version of PwerShell Needed
    1 Posts | Last post March 11, 2014
    • Will this script run on POwershell 1.0? We have a Server 2008 with SP1.
      
      Thanks
  • How to output to csv
    2 Posts | Last post October 04, 2012
    • I'm still very far from proficeint with powershell. How can I configure it to output to a csv. I've tried using Export-Csv but it seems to only output the final result.
    • Change this line:
      $results | Select-Object Folder, TotalSize , FileCount, SubDirs | Sort-Object TotalSize -Descending | Format-Table -auto 
      
      To:
      $results | Select-Object Folder, TotalSize , FileCount, SubDirs | Sort-Object TotalSize -Descending | Export-Csv -Path 'Results.csv' -NoType
  • Different method
    3 Posts | Last post November 10, 2011
    • Nice script! One thing that you could change is the following:
      
      $result = New-Object psobject -Property @{Folder =($dir.pspath -replace 'Microsoft\.PowerShell\.Core\\FileSystem::')
      
      Replace with:
      
      $result = New-Object psobject -Property @{Folder =(Split-Path $dir.pspath -NoQualifier)
    • Thanks, Boe.  I incorporated your suggestion, as well as fixing a bug, and adding the sub-directory count to the results.
      
      The problems were:
      1. Folders with one file were incorrectly being reported as having no files.  I fixed this with the 'if' statement.
      2. Folders were included in the filecount.  They are now separate.
    • Great job finding this, Boe! And thanks, Bigteddy, for the fix!