Reputation: 7555
I am currently using Pipeline
and PowerShell
to spawn a separate executable PowerShell script, with the help of Command
. Currently, I am invoking the executable from my original process asynchronously.
What I want to do is be able to allow the script or executable that I spawn to run independently of the current process. That way the script can kill the process that spawned it, without also dying. The behavior that I am experiencing right now is that when the script is run and it kills the process that spawned it, it too dies.
How can I spawn the secondary executable to be entirely independent so the process that spawned it can be killed, yet its execution will continue?
Upvotes: 0
Views: 415
Reputation: 68341
You can use Disconnect-PSSession
to disconnect your main process that spawned the job from the job session.
The job will continue to run, and you can use Connect-PSSession
from another PowerShell session later to re-connect to the session and receive the job data.
Upvotes: 1