Just use the command Select-Objectto return the first match. You do not need to use Get-ChildItem, since you can specify the path parameter in Select-String. The command Select-Stringreturns an object MatchInfothat contains the corresponding string, as well as the file name.
$m = Select-String -Pattern get -Path *.ps1 -list -SimpleMatch | select-object -First 1
$m.Line
$m.Path
source
share