使用answer时,Powershell'无法将参数绑定到参数'错误

时间:2017-06-17 16:10:25

标签: windows file powershell runtime-error

this question最受欢迎的答案涉及以下Windows PowerShell代码:

$file1 = Get-Content C:\temp\file1.txt  
$file2 = Get-Content C:\temp\file2.txt   
$Diff = Compare-Object $File1 $File2  
$LeftSide = ($Diff | Where-Object $_.SideIndicator -eq '<=').InputObject  
$LeftSide | Set-Content C:\temp\file3.txt

然而,当我尝试使用该代码时,我收到以下错误:

Where-Object : Cannot bind argument to parameter 'FilterScript' because it is null.

为什么我收到此错误,我该如何解决?

1 个答案:

答案 0 :(得分:1)

看起来像一个简单的语法错误。 Where-Object要求条件过滤器显示为脚本块(因此&#34; FilterScript&#34;):

Where-Object {$_.SideIndicator -eq '<='}