在Powershell中,我如何將標準輸出重定向到標準錯誤?Powershell將標準輸出重定向到標準錯誤
我知道我可以做反過來與2>&1
所以我嘗試:
echo "Hello" 1>&2
但我得到一個愚蠢的錯誤The '1>&2' operator is reserved for future use.
我問,因爲能夠做到這將使它更容易爲我調試另一個問題。見$LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError
您是否正在調用PowerShell寫入標準輸出的外部程序? –
是------------ –
那麼,爲什麼不只是捕獲它的輸出,並把它當作寫入標準錯誤呢? '$ output =&externalprog.exe 2>&1'。變量存儲您想要發送到標準錯誤的輸出。 –