select-string NOT working This topic contains 1 reply, has 2 voices, and was last updated by Olaf Soyk 1 year ago. Author Posts November 7, 2016 at 8:37 pm #57061 Kevin SextonParticipant I am trying to find the 1st occurrence of a string in each file. But it returns ALL the occurrences in each file. What am I doing wrong? Select-String -Path "c:\downloads\trash\*" -Pattern "aaa" C:\downloads\trash\1.txt:1:aaa C:\downloads\trash\1.txt:3:aaa C:\downloads\trash\3.txt:5:aaa C:\downloads\trash\3.txt:9:aaa November 7, 2016 at 9:28 pm #57064 Olaf SoykParticipant You're doing nothing wrong. That's what Select-String is made for. If you just want the first match: Select-String -Path "c:\downloads\trash\*" -Pattern "aaa" | Select-Object -First 1 Author Posts You must be logged in to reply to this topic.