2

I am trying to run multiple jobs in parallel using Start-Job cmdlet. I have huge environment setup which is ignored because Start-Job runs the jobs in new session. Is there any way to maintain the environment settings. I want it to fork basically.

kennyzx
  • 12,845
  • 6
  • 39
  • 83
Pankaj Garg
  • 893
  • 2
  • 8
  • 15

1 Answers1

0

The Start-Job cmdlet has switch -InitializationScript that is used to pass an initialization script that could contain the same env setup as the main session.

As per documentation:

-InitializationScript

Specifies commands that run before the job starts. Enclose the commands in braces ( { } ) to create a script block.

Use this parameter to prepare the session in which the job runs. For example, you can use it to add functions, snap-ins, and modules to the session.

Community
  • 1
  • 1
vonPryz
  • 22,996
  • 7
  • 54
  • 65