我试图这样做,但不起作用,任何想法?
if(Test-Path ~\desktop){
$bigfiles = Get-ChildItem ~\desktop -force -Include *.* | Where-Object {$_.Length -gt 10GB}
if{$bigfiles -gt 10GB){
echo "You have big files"
}
}
这是错误:
Cannot compare "C:\Users\mario\Desktop\AngelinaJolie_photo_in_4k.jpg" because it is not IComparable.
At line:7 char:8
+ if($bigfiles -gt 10GB){
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NotIcomparable
答案 0 :(得分:3)
FileInfo
,否则为FileInfo
的数组。您可以使用检查结果
if($bigfiles) { ... }