Start-Job输出在哪里?

Geo*_*uer 6 powershell

W:> $job = start-job { Write-Output "hi there"; throw "an error!" } | Wait-Job
W:> $job | select *


State         : Failed
HasMoreData   : True
StatusMessage :
Location      : localhost
Command       :  Write-Output "hi there"; throw "an error!"
JobStateInfo  : Failed
Finished      : System.Threading.ManualResetEvent
InstanceId    : 882957a9-a5e0-4876-bd22-0dbd87512f10
Id            : 7
Name          : Job7
ChildJobs     : {Job8}
PSBeginTime   : 3/24/2013 5:52:41 PM
PSEndTime     : 3/24/2013 5:52:47 PM
PSJobTypeName : BackgroundJob
Output        : {}
Error         : {}
Progress      : {}
Verbose       : {}
Debug         : {}
Warning       : {}
Run Code Online (Sandbox Code Playgroud)

我的输出在哪里?如何查看标准输出/错误流?

Ans*_*ers 23

作业在后台运行,因此它们不会写入控制台.您必须Receive-Job在作业完成后运行以收集其输出.

  • 完善.谢谢你,先生.我想补充一点,在尝试接收作业之前等待作业完成是很重要的. (2认同)