Get Top Level Folder Usage

This is too long to tweet, even written as a one liner. But this will search a folder for top level subfolders and return the file usage for each.

[cc lang=”PowerShell”]
dir $folder | where {$_.psIscontainer} | foreach {
$stat= dir $_.fullname -recurse | Measure-Object -property length -Sum
New-Object PSObject -property @{Folder=$_.FullName;Files=$stat.count;Size=$stat.Sum;}}

Again, this would be handy to turn into a function or scriptblock. This is far from perfect. For example, it doesn’t like empty folders. But this should be a good starting point for your own script or function.