I've been using the following piece of code to get the disk usage starting at a specific directory:
$usage = (Get-ChildItem $webRoot -recurse | Measure-Object -property length -sum)
$diskUsage = $usage.sum
The problem is that this takes a VERY long time compared with simply right clicking a directory in windows and looking at the properties.
Do we have access to the functionality that explorer uses to get disk usage? Or is there another way that will be faster than the method I've been using?
I'm also not sure what will happen if there are circular links in the area my PS code is searching. I assume it could lock up.