0

The most popular answer for this question involves the following Windows powershell code:

$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

Yet when I try to use that code, I get the following error:

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

Why am I getting this error, and how do I resolve it?

1 Answers1

4

Looks like a simple syntax error. Where-Object requires the conditional filter to be presented as a scriptblock (hence "FilterScript"):

Where-Object {$_.SideIndicator -eq '<='}
mjolinor
  • 66,130
  • 7
  • 114
  • 135