3

Is there any way, how to schedule Windows tasks|jobs on all servers from central location (server)? Has Microsoft any solution for this? I prefer MS or Windows Server built-in functionalities before SW from third party...

Thanks

[edit]: Sorry for incomprehensibility. I know, that I can manage tasks through "Task Scheduler" on remote server or I can manage them using PowerShell, but that's not easy centralized management. Cmdlet "Get-ScheduledTask" don't have "server" parameter, so I need to connect individualy to every server, run for example cmdlet "Get-ScheduledTask", than run on every task on that server "Get-ScheduledTaskInfo", because cmdlet "Get-ScheduledTask" itself tells you nothing and this way collect data from all servers? And not to mention editing tasks. That's really not a simple script. My idea is, that I have for example "Task Scheduler", but with tasks from all specified servers. Or at least PowerShell cmdlets with better approach to this task. I thought, that managing scheduled tasks on all servers from one place isn't so uncommon so it should be implemented into Windows Server. Need to write quite complicated scripts on such a common and simple thing....

(btw.. I'm using Windows Server 2012)

So I'm asking, if I missed something, or I really need to write that (quite long) script if I don't want to buy some third party software.

2
  • Can you maybe elaborate some more on what exactly you are trying to do?
    – MichelZ
    Apr 4, 2014 at 11:57
  • I'm sorry. I updated my question..
    – devlin
    Apr 4, 2014 at 17:29

5 Answers 5

2

You can use Group Policy Preferences to create a scheduled task and deploy it via GPO. This is probably the quickest way to get what you're looking for.

If you're entitled to System Center licensing, you should also explore System Center Orchestrator.

edit: I was so surprised that there were 4 previous answers that didn't mention GPO as a possibility, that I wrote a blog post with a quick rundown of how to do this.

1

By default, the Task Scheduler in Vista+ and Server 2008 R2+ will allow you to connect to a Task Scheduler on another computer.

enter image description here

You can also do so with PowerShell remoting (if you have an OS that supports those cmdlets), or via cmd.exe with WinRM or PSExec, if you want a fully scripted approach.

3
  • I need to have an overview, which tasks are scheduled on each server and I need to have an option to simply manage these tasks from one tool. I have around 30 servers, so connecting to each server separately through Task Scheduler GUI is really...... Yes, I know that I can use PowerShell and write a script which can do this, but I'm i little bit lazy, so I hoped that there is a tool for this :)
    – devlin
    Apr 4, 2014 at 13:50
  • 1
    @devlin Well, that's not what you asked, is it? You asked about scheduling tasks remotely, not about managing scheduled tasks on remote servers. :) Asking for a tool to do that is a product recomendation, and off-topic, here... but you might want to look at Task Scheduler Pro, or VisualCron. You can do the same thing with PowerShell, actually.. but since you're lazy and don't want to write that up... well, there ya go. Apr 4, 2014 at 13:54
  • I don't want to recommend software. I don't think, that this is off-topic. Sorry for incomprehensibility. I updated my question.
    – devlin
    Apr 4, 2014 at 17:32
1

The PS cmdlets do seem to be lacking for managing scheduled tasks, but I think you're overestimating the complexity of reporting on tasks, or creating the same task across multiple servers.

The SCHTASKS exe is useful tool for managing tasks programatically:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx

# Inventory Report
foreach ($server in gc .\serverList.txt) {
    write-warning $server
    SCHTASKS.EXE /s $server /query /fo csv > tasks.csv
    $csv = Import-Csv .\tasks.csv
    $csv | where {$_.taskname.lastindexof("\") -eq 0 -OR $_.taskname -match "\\Legacy" }    # Ignore bultin OS tasks from MS
}

# Create task if missing
foreach ($server in gc .\serverList.txt) {
    write-warning $server
    SCHTASKS.EXE /s $server /query /fo csv > tasks.csv
    $csv = Import-Csv .\tasks.csv
    if ( $csv.taskname.contains("\TaskNameToFind") ) {
        "Job already present"
    } else {
        SCHTASKS.EXE /s $server /Create /SC MONTHLY /MO first /D SUN /TN TaxTime C:\windows\system32\calc.exe
    }
}

You could similarly remove the same tasks across multiple servers by using the first half of the IF condition in the second example with the /DELETE operator.

1

It depends on what tasks you want to execute.

You can for example schedule a PowerShell command on one machine, which then in turn connects to other machines and executes powershell commands.

Edit:

After clarification from the OP, here's how you can execute the Command on a remote server from PS:

Invoke-Command -ComputerName MYCOMPUTERNAME -ScriptBlock {
        Get-ScheduledTask | Get-ScheduledTaskInfo | fl
}
1

To give you another angle - this normally is done using special centralized software and one that can do that is microsoft system center operations manager.

http://www.systemcentercentral.com/opsmgr-forum-discussion-task-automation-with-opsmgr-rules-or-windows-scheduled-tasks/

has some discussion about this.

An example for an enterprise task scheduler you can find at http://www.jamsscheduler.com/ - the feature list may enlighten you on why those exist.

Although once things get complex there is much better 3rd party software. Not as SCOM is bad - but it is not specializd as enterprise scheduling software, the scheduling part of part of some management pack. Enterpise Schedulers can run distributed workflows with complex dependencies (first run script a on those machines, once that is done that script on machine b, then back to cleanup scriptson the first set while yet another machine does file uploads).

The advantage of SCOM and enterprise schedulers is control, central, especially with specialized toold. Automation turns complex fast and an operations team must be able to see what is going on.

2
  • Don't forget about System Center Orchestrator (formerly Opalis). It's an automation engine from Microsoft.
    – MDMarra
    Apr 5, 2014 at 11:13
  • Yes, that one too ;) Plents of tools around.
    – TomTom
    Apr 5, 2014 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .