Geting Directory Size

Hi Guys,

I am new in Power shell. I will appreciate if somebody answer my question.

I am going to get the size of directory ( considering  subdirectories , files and folders ) . Here the command which I used:

"get-childitem -Path c:\windows\temp -recurse | measure-object -property Length -sum | select-object Count, Sum"

but I think the size of directories with this command  is a little less that size of my temp folder when I click on it with mouse and see properties. Does this command consider directory size ? or it just give me size of files on "temp" folder and its subdirectories?

Does "count" just show the number of files? How can I get number of files and folders?

Sorry for my English,



No Data
  • Martin 9700 said:

    I prefer the Measure-Object method with some calculated properties:


    $Path = "c:\Dropbox"
    Get-ChildItem $Path -Recurse -Force -File | Measure-Object Length -Sum | Select @{Name="Path";Expression={$Path}},@{Name="File Count";Expression={$_.Count}},@{Name="Size(MB)";Expression={"{0:N2} MB" -f ($_.Sum / 1mb)}}


    Oh wait.. FOLDER count too... trickier :)

No Data