not getting output from receive job
问题 The variable $var is blank when I run this script: function FOO { write-output "HEY" } $var = Start-Job -ScriptBlock { ${function:FOO} } | Wait-Job | Receive-Job $var How do I get output from receive-job? 回答1: Start-Job spawns a new PowerShell instance in the background and as such has no knowledge of your function FOO which is defined in your initial instance There is an additional parameter InitializationScript which is called upfront executing your script block in the new instance which