1

I am simply comparing 2 .csv files using compare-object with two fields of data and I am getting the expected results but the output format is just different . How do I extract the information from the results?

Compare-Object   $list1 $list -IncludeEqual  |Where-Object { $_.SideIndicator -eq '<=' }    | ft *
InputObject                                                   SideIndicator
"ABC123","4/11/2016 9:06:01 AM"                                    <=           
"XYZ456","4/11/2016 10:21:40 AM"                                   <=           
"FOO789","4/11/2016 10:12:43 AM"                                   <=    

How can I extract individual csv values from this output ?

5
  • 1
    You need to restore the inputobject that you see on the screen here. Compare-Object $list1 $list -IncludeEqual |Where-Object { $_.SideIndicator -eq '<=' } | Select-Object -ExpandProperty INputObject Commented Apr 11, 2016 at 18:20
  • @Matt , its getting better but its still showing both fields in one output "ABC123","4/11/2016 9:06:01 AM" , how can I get this split without usingsplit() to get results like "ABC123" "4/11/2016 9:06:01 AM" , I mean separate. Commented Apr 11, 2016 at 18:25
  • We need to see how you populate the $lists. Get-Content or Import-CSV? Commented Apr 11, 2016 at 18:37
  • This might have your answer: stackoverflow.com/questions/19040159/… Commented Apr 11, 2016 at 18:42
  • @Matt Lesson learned , I was using get-content with csv , BAD IDEA ! With CSV one should use import-csv. Thanks for pointing that out. Commented Apr 11, 2016 at 18:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.