2 Nov 2011

Getting the size of all files within a folder tree using Powershell


Here's a script that will output the size of all files within a folder, and the files in all its sub-folders. 

Outout in Kilobytes:

Get-ChildItem D:\Software -recurse | Select-Object Name, @{Name="KiloBytes";Expression={$_.Length / 1KB}} 

Outout in Megabytes:

Get-ChildItem D:\Software -recurse | Select-Object Name, @{Name="MegaBytes";Expression={$_.Length / 1MB}}