title: List file names in a folder matching a pattern, excluding file content
body: <p>I am using the below to recursively list all files in a folder that contains the <code>$pattern</code></p>
  
  <pre><code>Get-ChildItem $targetDir -recurse | Select-String -pattern "$pattern" | group path | select name
  </code></pre>
  
  <p>But it seems it both list files having the <code>$pattern</code> in its name and in its <em>content</em>, e.g. when I run the above where <code>$pattern="SAMPLE"</code> I get:</p>
  
  <pre><code>C:\tmp\config.include
  C:\tmp\README.md
  C:\tmp\specs\SAMPLE.data.nuspec
  C:\tmp\specs\SAMPLE.Connection.nuspec
  </code></pre>
  
  <p>Now:</p>
  
  <pre><code>C:\tmp\config.include
  C:\tmp\README.md
  </code></pre>
  
  <p>indeed contains the SAMPLE keywords/text but I don't care about that, I only need the command to list file names not file with content matching the pattern. What am I missing?</p>
  
  <p>Based on the below answers I have also tried:</p>
  
  <pre><code>$targetDir="C:\tmp\"
  Get-ChildItem $targetDir -recurse | where {$_.name -like "SAMPLE"} | group path | select name
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>$targetDir="C:\tmp\"
  Get-ChildItem $targetDir -recurse | where {$_.name -like "SAMPLE"} | select name
  </code></pre>
  
  <p>but it does not return any results.</p>