Start-Job输出在哪里?

时间:2013-03-24 22:54:58

标签: 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       : {}

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

1 个答案:

答案 0 :(得分:21)

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