Skip to content

Logging to console #290

@redwyre

Description

@redwyre

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):

function writeLog([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-Null
Register-ObjectEvent -InputObj $process -Event "ErrorDataReceived" -Action { writeLog(args) } -ErrorAction Stop | Out-Null

$process.Start() | Out-Null

$process.BeginOutputReadLine()
$process.BeginErrorReadLine()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions