Schtasks is your friend for this - AT is old and does not (SFAIK) comprehend tasks creates with schtasks. Unfortunately, the Win32_ScheduledTask WMI object is based on AT, otherwise it would be perfect for this.
Unfortunately, neither AT nor schtasks report on the user that the job runs as. There's probably a COM object somewhere that lets you get at that; maybe you could ask on stackoverflow?
If you want to script it you would probably do something like this:
$servers = 'server1','server2','server3'
$allTasks = @()
$servers | %{
$data = schtasks /query /S $_ /fo list
# Data looks like this:
# <blank line>
# HostName: [SERVER]
# TaskName: [TASK NAME]
# Next Run Time: 12:00:00 PM, 5/9/2009
# Status: [BLANK or SOME ERROR]
foreach ($line in $data){
$blob=""|select Host, Task, Next, Status
[void]$foreach.MoveNext(); $l = $foreach.Current.length;
$blob.Host = $foreach.current.substring(15, $l-15)
[void]$foreach.MoveNext(); $l = $foreach.Current.length;
$blob.Task = $foreach.current.substring(15, $l-15)
[void]$foreach.MoveNext(); $l = $foreach.Current.length;
$blob.Next = $foreach.current.substring(15, $l-15)
[void]$foreach.MoveNext(); $l = $foreach.Current.length;
$blob.Status = $foreach.current.substring(15, $l-15)
$allTasks += $blob
}
}
$allTasks|format-table
This has become an evil code essay - it would be easier to use the /FO csv option to dump to a text file the use import-csv to get the data back into PS, but that way you lose the server name. So instead you get to show off a bit and do custom object creation and hacking around with the foreach enumerator.
Calling MoveNext moves you to the next item in the list, so you skip the first empty line of output and then take each of the next 4 lines and make them into something useful.
It appears that there is more than just "regular" process priority at work here. As I noted in the question, the task scheduler by default runs your task at lower than normal priority. This question on StackOverflow describes how to fix any task to run at Normal priority, but the fix still leaves one thing slightly different: memory priority. Memory priority was a new feature for Windows Vista, and is described in this Technet article. You can see memory priority using Process Explorer, which is a must-have tool for any administrator or programmer.
Anyway, even with the scheduled task priority fix, the memory priority of your task is set to 4, which is one notch below the normal setting of 5. When I manually boosted the memory priority of my task up to 5, the performance was on par with running the process interactively.
For info on boosting the priority, see my answer to a related StackOverflow question about IO priority; setting memory priority is done similarly, via NtSetInformationProcess, with PROCESS_INFORMATION_CLASS
set to ProcessMemoryPriority
(the value of this is 39 or 0x27). I might make a free utility that can be used to set this, if others need it and don't have access to programmer tools.
EDIT: I've gone ahead and written a free utility for querying and setting the memory priority of a task, available here. The download contains both source code and a compiled binary.
Best Answer
This is only available in Windows 2012. You'd need to upgrade.