Olu Akin
Olu Akin

Reputation: 9

Filter First Column Text File (PowerShell)

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?

Upvotes: 0

Views: 1894

Answers (1)

Palle Due
Palle Due

Reputation: 6292

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.

Upvotes: 3

Related Questions