Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Using measure-object to determine size of a folder (Property "length" cannot be found)

$
0
0

I am have trouble getting the file size of a particular folder.

I am trying to do the following:

ls "\\someserver\c$\myfolder" | Measure-Object -Property length -sum

Measure-Object : Property "length" cannot be found in any object(s) input.
At line:1 char:35+ ls "\\someserver\c$\myfolder" | Measure-Object -Property length -sum+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException+ FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand

This folder is NOT empty and this method works on many other folders\servers. If I try using -ErrorAction SilentlyContinue it doesn't return anything. The only thing I can think of that is different about this folder is that it is a DFSR folder.

When a run the following to check each subfolder I see the error on a few subfolders (non of which are empty):

$Folders = Get-ChildItem '\\someserver\c$\myfolder'
$sum = $null
foreach ($Folder in $Folders)
    {
    $Folder.fullname
    ls $Folder.fullname | Measure-Object -Property length -sum #-ErrorAction SilentlyContinue
    #$sum += $sum
    }


\\someserver\c$\myfolder\folder1


Count    : 21
Average  : 
Sum      : 794925
Maximum  : 
Minimum  : 
Property : Length

\\someserver\c$\myfolder\folder2
Measure-Object : Property "length" cannot be found in any object(s) input.
At line:6 char:27+     ls $Folder.fullname | Measure-Object -Property length -sum #-ErrorAction Sil ...+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException+ FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand
\\someserver\c$\myfolder\folder3
Count    : 12
Average  : 
Sum      : 723851
Maximum  : 
Minimum  : 
Property : length

\\someserver\c$\myfolder\folder4
Measure-Object : Property "length" cannot be found in any object(s) input.
At line:6 char:27+     ls $Folder.fullname | Measure-Object -Property length -sum #-ErrorAction Sil ...+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException+ FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand
\\someserver\c$\myfolder\folder5
Count    : 6
Average  : 
Sum      : 15849403
Maximum  : 
Minimum  : 
Property : Length

\\someserver\c$\myfolder\folder6
Count    : 2
Average  : 
Sum      : 253061
Maximum  : 
Minimum  : 
Property : Length


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>