【发布时间】:2016-02-19 09:36:04
【问题描述】:
我正在尝试测量当前正在使用 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
如何测量仅包含由 BITS 下载器创建的 .tmp 文件的目录的递归大小。
【问题讨论】:
-
Get-ChildItem -Recurse怎么样?它有没有输出任何文件? -
感谢您的提示!问题是文件被隐藏了,需要使用
Get-ChildITem -Recurse -Hidden开关显示。
标签: powershell temporary-files sccm microsoft-bits