Suppose I have a simple Job that starts off like this:
$job = Start-Job -ArgumentList 1, 2 -ScriptBlock {
$var1 = $args[0]
$var2 = $args[1]
$var3 = $var1 + $var2
Write-Host $var3
}
Now suppose that I want to continue executing the session that is $job and introduce new arguments and simply continue executing inside $job.
From what I understand, that's not how Jobs work in Powershell. Once the commands inside the job were executed, the job is considered to be completed and can no longer be recycled. If my understanding is correct, is there any other way to achieve the effect of effectively having a background task inside your powershell session that you can continue injecting with new commands/variables, without having to create a new job/session/process? For clarity, this is local (on the same machine).