I have script which start several running script blocks by start-job
.
What's the best approach to pass some variables/values to the running background script block?
There are some options like service broker/queue, files, etc. Is there a lighter way?
For example,
$sb = {
$Value = $args[0] # initial value
while ($true)
{
# Get more values from caller
$Value = .....
}
}
start-job -ScriptBlock $sb -ArgumentList $initValue
# There are more values to send to the script after the script block is started.
while (moreVaulesAvailable)
{
# $sb.Value = .... newly generated values ?
}
Start-Job
started another PowerShell process. Is there any built-in mechanism to pass values between PS processes?