title: Multiple statements on a single variable in a pipeline
body: <p>I'm sure somehow somewhere this has been answered before but despite driving myself crazy I can't seem to find it.Newer to Powershell and coding in general, any critiques welcome.</p>
  
  <p>I want to look at a series of logs and output the name of the log followed by the number of times a string was found or the number of lines that contain a certain string.  Either should work.</p>
  
  <p>What I have right now is the following</p>
  
  <pre><code>$logsToCheck = "F:\errlog1.txt",
                  "F:\errlog2.txt"
  $errMatches = foreach($log in $logsToCheck)
       {Write-Host $log; Select-String -Path $log -Pattern "ERRORBAD"}
  $errMatches
  </code></pre>
  
  <p>My goal is something like an output of just the name of the log and the number of errors such as:</p>
  
  <pre><code>F:\errlog1.txt
  12
  F:\errlog2.txt
  7
  </code></pre>
  
  <p>I thought about just making variables for each log in the loop I have and printing the path name and then something like</p>
  
  <pre><code>$countErrLog1 = Select-String -Path F:\errlog1.txt -Pattern "ERRORBAD"
  $countErrLog1.Matches.Count
  </code></pre>
  
  <p>But that seems rather redundant.</p>
  
  <p>So what I end up looking for is how to pass multiple statements to a single variable in the pipeline before moving on to the next variable in the pipe.</p>
  
  <p>Thanks in advance.</p>