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 PsExec.exe
My code so fart that does work:
$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1"
Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments
Now the code with output redirection that doesn't work:
$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1 *> C:\temp\SetupNlb.log"
Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments
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.