Okay, here's a pseudo-code of what I'm trying to do:
Function DoThings() {
$OneJob = {
### things...
# I want to capture the STDOUT *and* STDERR of these three commands
A_Command >> "logfile.log" 2>&1
B_Command >> "logfile.log" 2>&1
C_Command >> "logfile.log" 2>&1
}
$params = @{ }
For ($i=1; $i -lt 100; $i++) {
### Manipulate $params here
Start-Job $OneJob -ArgumentList $params
}
}
However, naively running the above resulted in several jobs ending with errors, because apparently "logfile.log" is being opened by another job running at the same time.
So, how do I ensure that all jobs will not step on each other's shoes when writing to the "logfile.log" file?