Created
August 3, 2015 13:02
-
-
Save msmorul/c97a51f9c5884eec60e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Print a summary of disk usage in the supplied directory | |
# -directory <directory> | |
# | |
Param( | |
[parameter(Mandatory=$true)] | |
[alias("d")] | |
$directory | |
) | |
gci $directory | %{$f=$_; $d = gci -r $_.FullName; $r = Measure-Object;try { $r = %{ $d | measure-object -property length -sum -ErrorAction Stop }} catch { $r.Sum = 0; } ; $r | select @{Name="Name"; Expression={$f}} , @{Name="Sum (MB)"; Expression={ "{0:N3}" -f ($_.sum / 1MB) }}, Sum } | sort Sum -desc | format-table -Property Name,"Sum (MB)", Sum -autosize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment