【问题标题】:Where does Start-Job output go?Start-Job 输出在哪里?
【发布时间】:2013-03-24 22:54:58
【问题描述】:
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       : {}

我的输出去哪儿了?如何查看标准输出/错误流?

【问题讨论】:

    标签: powershell


    【解决方案1】:

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

    【讨论】:

    • 完美。谢谢你,先生。我要补充一点,在尝试接收作业之前等待作业完成似乎很重要。
    • @GeorgeMauer 确实如此。我在答案中添加了这个细节。
    • 我没有看到这种行为。相反,我的控制台随机地从工作中获得大量输出。我没有使用 Wait-Job
    • 你不必等待,看我的answer
    猜你喜欢
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    相关资源
    最近更新 更多