# Script: foldersize.ps1
# Usage: Change the working directory where you want to list get size of the folders
# Run the script as c:
foldersize.ps1
# If you want to create a file with the results of this code, run this script as
# C:foldersize.ps1 > homefolders.txt
#
# Written by Anand Venkatachalapathy
# Date Written: Jan 18 2010
get-childitem | where {$_.PSIsContainer} | foreach {
$size = (Get-ChildItem $_ -recurse | where {!$_.PSIsContainer} | Measure-Object -Sum Length).Sum
$obj = new-object psobject
$size /= 1073741824
if ($size -lt 1) { continue }
add-member -inp $obj noteproperty path $_.fullName
add-member -inp $obj noteproperty size $size
$obj
}