Powershell Start-job synchronous output

Question:

I have a powershell script that starts a job

and then it continues executing the rest of the script.

That job, is kind of a monitoring one for the PID of that process.

I would like to synchronously print the PID every n seconds, without having to end the job.

For example, as the rest of the script is being executed, i would like to see output in my console.

Is something like that possible in powershell?

Thanks.

Answer:

Yes, you can use events:

Credit goes to this answer. Other useful links:

Source:

Powershell Start-job synchronous output by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply