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.
Can I just copy the .job files to the
new server and reset the passwords?
No. Basically, the job files under Windows 2003 and Windows 2008 are of different format (binary vs. XML-based)
If this is not possible, is there a
way to turn each .job file into a user
readable format, or even better,
reverse engineer to a command line
statement or script?
I know someone wrote a perl script to parse the binary data of Task Scheduler 1.0 job files into human-readable.
Take a look here.
Best Answer
Looks like they were discussing the problem here: http://social.technet.microsoft.com/Forums/en-US/itprovistamigration/thread/76b6276b-49f2-41e2-b4ea-f537e0eb88a8
Seems like there is no current approved method of doing this.
However one user in that forum posted this:
If you run schtasks from the vista/2008 server maching you can export the xp/2003 schtasks to xml. schtasks /query /s xpmachine /tn taskname /XML > taskname.xml then you can import it. not perfect but can save time. i exported the tasks using /fo table opened that to excel deleted unneeded columns and created a batch file to dump the xmls then /create /xml xmlfile.xml to import the xmls to the new server. hope this helps.
So it seems possible but it needs some jiggery pokery.
I tried it out myself but kept on getting access denied errors from Win2008. Even though I was the network admin with all privileges. Maybe someone else could make an attempt?
EDIT-Solution:
I have tried this personally and yes it does work. It would only take a little more effort to script it. You just need to leave the xp files on the vista machine. You could then export them as XML via script as well.
Link: From experts exchange