Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Stop a PowerShell Job

$
0
0

Summary: Learn how to stop an unwanted Windows PowerShell job.

Hey, Scripting Guy! Question How can I stop an over-running Windows PowerShell job?

Hey, Scripting Guy! Answer Even though this is not something you’d normally do, creating an infinite loop is a common (and
          potentially, very embarrassing) error. This job will run forever:

Start-Job -ScriptBlock {while ($true){sleep -Seconds 10}}

When you realize that your job is over-running, use the Stop-Job cmdlet:

Stop-Job -Id 14

You can then hide the evidence by using Remove-Job to delete the job.
You can test the data in the stopped job with Receive-Job, if desired, before you delete the job.


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>