title: Powershell Get-Content with Where-Object
body: <p>I have a file like this:</p>
  
  <pre><code>line one email1
  line two email1
  line three email2
  line four email1
  </code></pre>
  
  <p>If I want to extract only the lines that contain "email1", I do this:</p>
  
  <pre><code>$text = Get-Content -Path $path | Where-Object { $_ -like *email1* }
  </code></pre>
  
  <p>$text is now an array with 3 elements containing those lines, and I iterate through it like this:</p>
  
  <pre><code>for ($i = 0; $i -lt $text.Length; $i++)
  {
  #do stuff here
  }
  </code></pre>
  
  <p>However, if I want to get the lines containing "email2".</p>
  
  <pre><code>$text = Get-Content -Path $path | Where-Object { $_ -like *email2* }
  </code></pre>
  
  <p>returns a string, rather than an array of one element.
  And when I iterate through it, it iterates through each char in the string.</p>
  
  <p>How can I make it an array with one element rather than a string?</p>