title: Can't redirect PowerShell output when -EncodedCommand used
body: <p>For my tests I am using 'Start > Run' dialog (not the cmd.exe).</p>
  
  <p>This works fine, and I get 9 in log.txt</p>
  
  <pre><code>powershell -Command 4+5 &gt; c:\log.txt
  </code></pre>
  
  <p>But this does not work:</p>
  
  <pre><code>powershell -EncodedCommand IAA1ACsANwAgAA== &gt; c:\log.txt
  </code></pre>
  
  <p>So how can I redirect output in this case?</p>
  
  <p>Experimental code:</p>
  
  <pre><code>function Test
  {
      $cmd = { 5+7 }
      $encodedCommand = EncodeCommand $cmd
  
      StartProcess "powershell -Command $cmd &gt; c:\log.txt"
      StartProcess "powershell -EncodedCommand $encodedCommand &gt; c:\log2.txt"
  }
  
  function StartProcess($commandLine)
  {
      Invoke-WMIMethod -path win32_process -name create -argumentList $commandLine
  }
  
  function EncodeCommand($expression)
  {
      $commandBytes = [System.Text.Encoding]::Unicode.GetBytes($expression)
      [Convert]::ToBase64String($commandBytes)
  }
  </code></pre>