How do I Start a job of a function i just defined?
问题 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 \'FOO\' is not recognized as the name of cmdlet, function ,script file or operable program. What do I do? Thanks. 回答1: As @Shay points out, FOO needs to be defined for the job. Another way to do this is to use the -InitializationScript parameter to prepare the session. For your example: $functions = { function FOO { write-host "HEY" } }