title: Powershell not recognizing legitimate commands when running batch file?
body: <p>As I'm just learning Powershell, I want to write a simple batch script that counts the number of lines in a text file and prints it to console window at the end. I wrote</p>
  
  <pre><code>Clear-Host
  $counter=0
  for /f %%j in (someText.txt) do (
      $counter++
  )
  $counter
  </code></pre>
  
  <p>I ran the script in Powershell and got the following error:<br>
  <em>'Clear-Host' is not recognized as an internal or external command,
  operable program or batch file.<br>
  '$counter' is not recognized as an internal or external command,
  operable program or batch file.<br>
  '$counter++' is not recognized as an internal or external command,
  operable program or batch file.</em></p>
  
  <p>This is very befuddling to me, since when I enter individual commands like "$counter=0" and "$counter++" into Powershell, no errors occur and I get the expected behavior: I initialize a counter variable, and then increment it by one. 
  <br>
  <br>
  Also, how do I enter an entire loop (or some other multi-line code construct) in Powershell?...entering it as a one-liner like <code>for /f %%j in (someText.txt) do ($counter++)</code> gives me <br><br>
  <em>At line:1 char:4<br>
  + for /f %%j in (someText.txt) do (<br>
  +    ~<br>
  Missing opening '(' after keyword 'for'.<br>
  At line:1 char:33<br>
  + for /f %%j in (someText.txt) do (<br>
  +                                 ~<br>
  An expression was expected after '('.<br>
  At line:1 char:33<br>
  + for /f %%j in (someText.txt) do (<br>
  +                                 ~<br>
  Missing closing ')' in expression.<br>
      + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
      + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword</em></p>
  
  <p>I also tried using cmd.exe instead of Powershell--I get all the same problems described above.
  Any idea how I can make my script do what it's supposed to?</p>