how to compare two csv files in powershell without specifying properties

后端 未结 2 1919
生来不讨喜
生来不讨喜 2021-01-15 13:29

I have two csv files:

ipaddress,port
10.140.11.1,80
10.140.11.2,80
ipaddress,port
10.140.11.1,80
10.140.11.2,8008

The question is how to

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 14:19

    The answer by latkin will not work. You will get the following exception:

    Compare-Object : Cannot convert System.Management.Automation.PSObject to one of the following types {System.String, System.Management.Automation.ScriptBlock}. At line:8 char:19 + Compare-Object <<<< $file1 $file2 -Property $props1 + CategoryInfo : InvalidArgument: (:) [Compare-Object], NotSupportedException + FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.CompareObjectCommand

    It seems that one cannot pass a variable for -Property. It has to be a comma-seperated list of NoteProperties and it cannot be enclosed in single or double quotes.

    I've been looking for a way to do this same thing and I still haven't found a way...

提交回复
热议问题