Reputation: 65
I was writing a power shell script to get a size of directory
(get-childitem <path> -recurse | measure-object -property length -sum).sum/1MB
now I want both "size" and "size on the disk" of a folder to be displayed as output
Upvotes: 3
Views: 7124
Reputation: 447
Try this:
GCI <Path> -Recurse |
Group-Object -Property Directory | % {
New-Object psobject -Property @{
Name = $_.Name
Size = ($_.Group | ? {!($_.PSIsContainer)} | Measure-Object Length -Sum).Sum
}
} |
Sort-Object -Property Size -Descending
Upvotes: 3