All, Hit send too soon - I saw a couple of other things:
Some of the directories have spaces in them, which cause an error when trying to work their subdirectories, like so: K:\Engineering\x1\y 1\CurrentVersions measure-object : The property "length" cannot be found in the input for any objects. At line:3 char:151 + ... ct -first 32 | measure-object -property length –sum) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Measure-Object], PSArgumentException + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand So, obviously, this has to be dealt with as well. My problem is that when I used: $CurrentVersions = Get-ChildItem K:\Engdrops -directory -filter CurrentVersions -recurse instead of $CurrentVersions = Get-ChildItem K:\Engdrops -directory -filter CurrentVersions -recurse | select -expand fullname and tried to work with that in the rest of the script, I couldn't get the $CurrentVersion.fullname into the output. Utterly failed at that. Thanks again, Kurt On Thu, Jul 20, 2017 at 8:04 PM, Kurt Buff <kurt.b...@gmail.com> wrote: > 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