title: start a PowerShell script as local system user and redirect the script output
body: <p>I need to start a PowerShell script as user "nt authority\system" and want to redirect the output of the script to a file. To start PowerShell as system user I use <a href="https://blogs.msdn.microsoft.com/sonam_rastogi_blogs/2017/01/16/run-powershell-using-local-system-account/" rel="nofollow noreferrer">PsExec.exe</a><br>
  My code so fart that does work:</p>
  
  <pre><code>$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1"
  Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments
  </code></pre>
  
  <p>Now the code with output redirection that doesn't work:</p>
  
  <pre><code>$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1 *&gt; C:\temp\SetupNlb.log"
  Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments
  </code></pre>
  
  <p>The problem could be that the -File parameter of Powershell.exe should be the last parameter but i think the redirection of the output/streams as well.</p>