I have a large directory, with multiple (80+) subdirectories, each of
which has its own subdirectory for which I'm trying to find the
largest 32 items, and sum them. I'm using this article:
https://blogs.technet.microsoft.com/askds/2011/07/13/how-to-determine-the-minimum-staging-area-dfsr-needs-for-a-replicated-folder/
to determine the optimum cache size for DFRS for the
sub-sub-directories that will be replicated.

This works just fine for a single directory:
   $CurrentVersion = "K:\Engineering\x1\y1\CurrentVersions"
   $CurrentVersionLargest32 = Get-ChildItem $CurrentVersion -recurse |
Sort-Object length -descending | select-object -first 32 |
measure-object -property length –sum

This fails:

   $CurrentVersions = Get-ChildItem K:\Engineering -directory -filter
CurrentVersions -recurse | select -expand fullname
   $CurrentVersionsOut = @()
   foreach ($CurrentVersion in $CurrentVersions)
      {
         $CurrentVersionLargest32 = $CurrentVersion.(Get-ChildItem
$CurrentVersion -recurse | Sort-Object length -descending |
select-object -first 32 | measure-object -property length –sum)
         $CurrentVersionCacheSize =
[math]::Round($CurrentVersionLargest32.sum /1gb)
         $CurrentVersionsOut += [pscustomobject]@{SourceContentPath =
$CurrentVersion; SourceConflictAndDeletedQuotaInMB =
$CurrentVersionCacheSize }
      }
   $CurrentVersionsOut | export-csv -notype c:\temp\CacheSizes.csv

Output looks like this:
   "SourceContentPath","SourceConflictAndDeletedQuotaInMB"
   "K:\Engineering\x1\y1\CurrentVersions","0"
   "K:\Engineering\x2\y2\CurrentVersions","0"

So, to me, after much testing, it looks like I've got something wrong
with the first line inside the foreach loop, but I've banged my head
against that for several hours, and just can't seem to figure it out.

Pointer in the correct direction would be much appreciated.

Kurt




Reply via email to