Scheduling tasks|jobs across servers from central location. (Windows Server)

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.


Solution 1:

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.

Solution 2:

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.

Solution 3:

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.