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.
Asked
Active
Viewed 445 times
1 Answers
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.