比较数据时的powershell混淆

时间:2017-12-04 19:12:53

标签: powershell compare

我的脚本正在搜索大于N尺寸的powershell v2目录,提示用户在哪里查看

module top;
reg [7:0] a;
reg [0:7] b;
initial begin
  a[2] = 1'b1;
  b[2] = 1'b1;
  $displayb(a,,b);
end 
endmodule

运行脚本会抛出错误:

1 write-host -foreground green "path to search"
2 $location = read-host
3 write-host -foreground green "how about the size (GB)"
4 $size = read-host
5 $unit = "GB"
6 $threshold = $size + $unit
7 $fso = New-Object -COM 'Scripting.FileSystemObject'
8
9 Get-ChildItem $location -Recurse -Force -ErrorAction SilentlyContinue | Where-Object 
{
    $_.PSIsContainer -and $fso.GetFolder($_.FullName).Size -gt $threshold
}

但如果我直接在Powershell应用中运行第7行和第9行:

Bad argument to operator '-gt': Could not compare "10689" to "1GB". Error: "Cannot convert value "1GB" to type "System
Int32". Error: "Input string was not in a correct format."".

在我提供" 1GB"从CLI,它的工作原理。为什么?

0 个答案:

没有答案