Skip navigation
QA

Trigger Action from PowerShell Without Waiting for It to Complete

Q: I want to trigger something from my PowerShell script but not wait for it to finish nor have it connected to the ongoing connection of my script; how can I do this?

A: There are a number of ways to achieve this; however, the easiest method is probably to use the Start-Job cmdlet and pass a script block of what you want to run; for example:

Start-Job -ScriptBlock {<code to run>}

Other options including running a task asynchronously with BeginInvoke and EndInvoke; however, if the parent PowerShell process dies, then the called process would also die.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish