Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are 'Scheduled Job" and "Scheduled Task" the same thing in Powershell context?

I am trying to create a scheduled task from Powershell.

I was readin the document for cmdlet: New-ScheduledJobOption.

And I am a bit confused...

Question: Are 'Scheduled Job" and "Scheduled Task" the same thing in Powershell context? Or there is a difference?

like image 441
pencilCake Avatar asked May 05 '14 07:05

pencilCake


2 Answers

So just to put an actual answer out there, in addition to the article Valamus put out:

In a PowerShell context Scheduled Jobs and Scheduled Tasks are not the same thing. From a task scheduler perspective they are exactly the same thing.

The PowerShell team provided a toolset for creating a special type of job that would be stored in the Task scheduler library. The Scheduled Jobs cmdlets will not allow you to interact with regular scheduled tasks. The Task Scheduler will let you interact with regular tasks and scheduled jobs interchangeably.

like image 115
Jason Morgan Avatar answered Oct 15 '22 10:10

Jason Morgan


Scheduled Task is just a Windows thing and PowerShell can control it in the same way it (PowerShell) can control many other Windows things.

Scheduled Job is, in the other hand, mostly PowerShell thing. Namely, scheduled job is some PowerShell code scheduled for execution in a "Windows Task Scheduler" manner and executed within PowerShell environment (naturally).

So, an activity run as a Scheduled Task is anything you can run from command prompt (eg. .EXE, .BAT, .COM, .CMD etc. - nothing PowerShell-ish, unless you decide to start powershell.exe and give it some script name to execute. Yet, you can control all of that from PowerShell.

On the other hand, Scheduled Job is exclusively PowerShell code (be it script block or script file) that PowerShell registers with Windows Task Scheduler, and Windows Task Scheduler knows how to activate it. Method of repetitive activation is in both cases the same ("triggers").

So, Powershell Scheduled Task is a Windows thing (controllable also from PowerShell), while PowerShell Scheduled Job is a exclusively PowerShell thing.

like image 38
Gjuro Kladaric Avatar answered Oct 15 '22 08:10

Gjuro Kladaric