I need to get the size of a Directory - recursive -. I Have to do this every month so I want to make a powershell script to doit, Any Help?

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

I asked the same question in stackoverflow and I get this excelent answer:

function Get-DirectorySize() {
  param ([string]$root = $(resolve-path .))
  gci -re $root |
    ?{ -not $_.PSIsContainer } | 
    measure-object -sum -property Length
}

This actually produces a bit of a summary object which ill include the Count of items. You can just grab the Sum property though and that will be the sum of the lengths

$sum = (Get-DirectorySize "Some\File\Path").Sum

Thanks JaredPad

link|improve this answer
feedback

Check this post out.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.