获取使用 PowerShell 的 'Start-Job' 命令启动的子作业的输出
Get the output of sub jobs started with 'Start-Job' command of PowerShell
我有一个包含以下代码的 PowerShell 脚本:
$functions = {
Function test_function()
{
echo "hello world"
}
}
Function test_launcher()
{
$EO = Start-Job -InitializationScript $functions -ScriptBlock {test_function} | Wait-Job
$KK = Receive-Job -Job $EO
echo $KK }
test_launcher
但是不知道为什么'Hello world'这个字符串没有打印出来。有谁知道如何修改此代码以获得屏幕上打印的子作业 'test_function' 的结果?
您需要检索您开始的工作 - 查看 Receive-Job
我有一个包含以下代码的 PowerShell 脚本:
$functions = {
Function test_function()
{
echo "hello world"
}
}
Function test_launcher()
{
$EO = Start-Job -InitializationScript $functions -ScriptBlock {test_function} | Wait-Job
$KK = Receive-Job -Job $EO
echo $KK }
test_launcher
但是不知道为什么'Hello world'这个字符串没有打印出来。有谁知道如何修改此代码以获得屏幕上打印的子作业 'test_function' 的结果?
您需要检索您开始的工作 - 查看 Receive-Job