22

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?

pencilCake
  • 51,323
  • 85
  • 226
  • 363
  • Is it easier to just run the command and see if it appears as a scheduled task? (did not neg u) – Valamas May 05 '14 at 07:27
  • 1
    I am not questioning the behavior but trying to understand the terminology. – pencilCake May 05 '14 at 07:28
  • 4
    Check this page out: http://blogs.technet.com/b/heyscriptingguy/archive/2013/11/23/using-scheduled-tasks-and-scheduled-jobs-in-powershell.aspx – Valamas May 05 '14 at 07:32
  • Scheduled Jobs are a subset of Scheduled Tasks. The link @Valamas-AUS gave is a good overview. – alroc May 05 '14 at 11:22

2 Answers2

13

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.

mklement0
  • 382,024
  • 64
  • 607
  • 775
Jason Morgan
  • 1,055
  • 7
  • 10
12

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.

Gjuro Kladaric
  • 149
  • 1
  • 2