I am trying to write a PowerShell command to return the size of each immediate sub-folder. The script should return the size of the size of the file layer of subfolders and for each subfolder the sum of all of its decedents. I have written the following and it give me the info, however in doing so I lost the folder name property.
gci -Directory | ForEach-Object {Get-ChildItem -file $_ -Recurse | Measure-Object -sum length} |Format-Table
Namely I need the name first layer displayed along side the sum of length of all of its subsequent decedents.
How do I achieve this?