How do I Start a job of a function i just defined?

后端 未结 7 770
臣服心动
臣服心动 2020-11-27 23:34

How do I Start a job of a function i just defined?

function FOO { write-host \"HEY\" } Start-Job -ScriptBlock { FOO } |
Receive-Job

Receive-Job: The term \'         


        
相关标签:
7条回答
  • 2020-11-28 00:13

    The function needs to be inside the scriptblock:

    Start-Job -ScriptBlock { function FOO { write-host "HEY" } ; FOO } | Wait-Job | Receive-Job
    
    0 讨论(0)
提交回复
热议问题