Using the argument -Logfile - doesn't work, though I haven't been able to get it work at all in powershell so I'm not sure if there are other issues going on.
This is what I ended up with, even if it didn't work (using the add event function crashed with a stack overflow so using Register-ObjectEvent):
functionwriteLog([System.Object] $sender, [System.Diagnostics.DataReceivedEventArgs] $e) {
if ($e.Data) { Write-Output$e.Data }
}
Register-ObjectEvent-InputObj $process-Event "OutputDataReceived"-Action { writeLog(args) } -ErrorAction Stop |Out-NullRegister-ObjectEvent-InputObj $process-Event "ErrorDataReceived"-Action { writeLog(args) } -ErrorAction Stop |Out-Null$process.Start() |Out-Null$process.BeginOutputReadLine()
$process.BeginErrorReadLine()
Using the argument
-Logfile -doesn't work, though I haven't been able to get it work at all in powershell so I'm not sure if there are other issues going on.This is what I ended up with, even if it didn't work (using the add event function crashed with a stack overflow so using Register-ObjectEvent):