Newbie to PowerShell.
I want to filter in column 1 where value in a text file equal "Find"
Get-Content -Path C:\home\file.csv | Select-String -SimpleMatch "Find"
When I ran the above script it returns all records in column 1 that equal "Find" and other columns that have "Find", it should only return column 1 where value is "Find"
Please can you help?
–
Use Import-csv:
Import-Csv C:\home\file.csv -Header Col1,Col2,Col3 | Select-Object -Unique Col1 | Select-String -SimpleMatch "Find"
Adjust the header columns to the columns you have. I assume you have no headers in the csv. otherwise it would be even easier.
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0
with attribution required.
rev 2020.2.12.36053