Powershell: Get Size of Child Directories
gci -recurse -force |
? { $_.GetType() -like 'System.IO.DirectoryInfo'} |
select-object Name,@{Name="size"; Expression = {
($_.GetFiles() |
Measure-Object -Property Length -Sum |
Measure-Object -Property Sum -Sum).Sum}} | sort-object -Property size

2 comments:
Did you obfuscate this or is PowerShell really that non-obvious to read?
Well, I'm surely not the best PowerShell scripter around, so there may be simpler ways to get this done. I did use a lot of the syntax shortcuts (e.g. ? = Where-Object, % ForEach-Object). To really answer your question though, I could simply say the reason I post these is so I don't have to write them again later. I can just search my blog for them.
Post a Comment