How do I write to standard error in PowerShell?

前端 未结 3 544
遥遥无期
遥遥无期 2020-11-30 04:00

I\'m having trouble figuring out how to both echo to the standard error stream and redirect the error stream of an executable.

I have come from a Bourne shell and Ko

3条回答
  •  -上瘾入骨i
    2020-11-30 04:24

    You probably want this:

    $host.ui.WriteErrorLine('I work in any PowerShell host')
    

    You might also see the following, but it assumes your PowerShell host is a console window/device, so I consider it less useful:

    [Console]::Error.WriteLine('I will not work in the PowerShell ISE GUI')
    

提交回复
热议问题