title: How can I start a background job in Powershell that outlives it's parent?
body: <p>Consider the following code:</p>
  
  <pre><code>start-job -scriptblock { sleep 10; cmd /c set &gt; c:\env.txt; }
  exit
  </code></pre>
  
  <p>The background job is killed when the parent exits, so the call to cmd.exe never occurs. I would like to write some similar code, such that the parent exits immediately, and the child continues to run in the background.</p>
  
  <p>I would like to keep everything in one script if possible.</p>