現在 BITS でダウンロードされている ccmcache ディレクトリの再帰的なサイズを測定しようとしています。
次の Powershell スクリプトを使用して、ディレクトリの再帰的なサイズを測定しています。
(Get-ChildItem $downloadPath -recurse | Measure-Object -property Length -sum).Sum
このスクリプトは「通常の」ディレクトリとファイルに対して機能しますが、ディレクトリにファイルしか含まれていない場合、次のエラーで失敗し.tmp
ます。
Measure-Object : The property "Length" cannot be found in the input for any objects.
At line:1 char:27
+ (Get-ChildItem -Recurse | Measure-Object -Property Length -Sum).Sum
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Measure-Object], PSArgumentException
+ FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand
.tmp
BITS ダウンローダーによって作成されたファイルのみを含むディレクトリの再帰的なサイズを測定するにはどうすればよいですか。