Вы не показываете, как выглядит ваш CSV-файл, так что есть, но шаг за шагом, что вы ищете.
($a = Get-Content -Path 'D:\Documents\file1.txt')
($b = Get-Content -Path 'D:\Documents\file2.txt')
Compare-Object -ReferenceObject $a -DifferenceObject $b
<#
What's in the two files
file1
hello
world
file2
hello
world
InputObject SideIndicator
----------- -------------
file2 =>
file1 <=
#>
($a = Get-Content -Path 'D:\Documents\file1.csv')
($b = Get-Content -Path 'D:\Documents\file2.csv')
Compare-Object -ReferenceObject $a -DifferenceObject $b
<#
What's in the two files
Col1,Col2,Col3
file1,hello,world
Col1,Col2,Col3
file2,hello,world
InputObject SideIndicator
----------- -------------
file2,hello,world =>
file1,hello,world <=
#>
($a = (Get-Content -Path 'D:\Documents\file1.csv' | Select -Skip 1) -split ',')
($b = (Get-Content -Path 'D:\Documents\file2.csv' | Select -Skip 1) -split ',')
Compare-Object -ReferenceObject $a -DifferenceObject $b
<#
file1
hello
world
file2
hello
world
InputObject SideIndicator
----------- -------------
file2 =>
file1 <=
#>
Наконец, это также звучит до жути вот так Q & A
Сравните два списка в Powershell