title: How to run a PowerShell script as a job in Jenkins
body: <p>This sounds like a simple question, but I haven't been able to work it out after looking online. I basically want to execute a PowerShell script (e.g. script.ps1) in Jenkins and report success/failure.</p>
  
  <p><strong>Try 1:</strong> Run following as "Execute Windows Batch Command"</p>
  
  <pre><code>powershell -File c:\scripts\script.ps1
  </code></pre>
  
  <p>This starts up as expected, but it quits after a few seconds.</p>
  
  <p><strong>Try 2:</strong> Run following as "Execute Windows Batch Command"</p>
  
  <pre><code>powershell -NoExit -File c:\scripts\script.ps1
  </code></pre>
  
  <p>This runs the whole script successfully, but it never stops. I had to manually abort the script.</p>