Starting Situation
- A number of tasks might be running in JobScheduler that should immediately be killed.
- This could happen
- due to some misbehaving scripts that cause a large number of job starts.
- due to a business requirement for an emergeny stop.
Use Cases
Kill all tasks
C:\PS> Get-JobSchedulerTask | Stop-JobSchedulerTask
- The
Get-JobSchedulerTaskcmdlet retrieves all running tasks. - The list of tasks is piped to the
Stop-JobSchedulerTaskcmdlet. - Depending on the system load the killing of tasks might take some seconds. Repeatedly executing the
Get-JobSchedulerTaskcmdlet should prove that no further tasks are running.
Kill tasks for any running jobs that are located in a folder
C:\PS> Get-JobSchedulerJob /some_folder -Recursive -Running | Stop-JobSchedulerTask
- The
Get-JobSchedulerJobcmdlet retrieves jobs starting from the specified directory. Any sub-folders of that directory are included if the-Recursiveparameter is specified. - The list of tasks is pipelined to the
Stop-JobSchedulerTaskcmdlet.
Kill tasks for any jobs of a job chain
C:\PS> Get-JobSchedulerJobChain -JobChain /some_folder/some_job_chain | Get-JobSchedulerJob -Running | Stop-JobSchedulerTask
- The
Get-JobSchedulerJobChaincmdlet retrieves the specified job chain. - The
Get-JobSchedulerJobcmdlet retrieves jobs for the resulting job chain(s). - The list of tasks is piped to the
Stop-JobSchedulerTaskcmdlet.
See also
- The
Stop-JobSchedulerTaskcmdlet supports a number of actions to kill (sending SIGKILL) and to terminate (sending SIGTERM) signals to processes, For details see How to Terminate Tasks.