Home > other >  Powershell compare two CSV files, how do you make it case-insensitive?
Powershell compare two CSV files, how do you make it case-insensitive?

Time:11-22

I have two CSV files I am comparing, one has two columns, the second file has three. I am needing the output of all three columns from the input from the first CSV file.

The code I am currently using is as follows

$ErrStatus = Import-Csv .\StatusErrorResults.csv

$StatLibrary = Import-Csv .\Status_Library.csv

Compare-Object $StatLibrary $ErrStatus -Property Device,Status -IncludeEqual -ExcludeDifferent -PassThru | Select-Object \* -ExcludeProperty SideIndicator | Export-Csv -NoTypeInformation .\StatusErrorResultsFiltered.csv"

It is ignoring a section of the Status Library due to case sensitivity, how can I include regardless of case?

CodePudding user response:

Compare-Object is case-insensitive by default, but you have -CaseSensitive switch to change that.

  • Related