Is there a MS windows built in utility or powershell cmdlet to export all scheduled tasks from a Domain controller?

Hi Experts,

I would like to export all scheduled tasks from a windows 2008 r2 domain controller onto a spread sheet or csv,txt file. I would like to see task name, triggers, last time execution, so forth

Any ideas?
Jerry SeinfieldAsked:
Who is Participating?
 
SeanSystem EngineerCommented:
to do it through the GUI you need to do them one at a time.
0
 
SeanSystem EngineerCommented:
0
 
SeanSystem EngineerCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Steven CarnahanNetwork ManagerCommented:
I can't remember where I found it but here is a batch file that takes a text file list of servers and can get all the scheduled tasks from those servers:

 ::This script Checks and Lists all Scheduled tasks from a list of server 
 :: By Felipe Ferreira 22/08/2007 
:: Usage:  aschtask servers.txt (from command prompt)
  
 @echo off 
 :: Keep variables local, and Define Logfile 
 SETLOCAL 
 del list_scheduled.TXT /q 
 set logfile=list_scheduled.TXT 
  
 :: Read variables from command line 
 SET TXTFile="%~f1" 
  
 :Run 
 cls 
 @echo. 
 @echo Retriving Scheduled jobs from %TXTFile% please wait... 
 @echo. 
  
 :: Search the TXT file line by line 
 FOR /F "tokens=* delims=" %%A IN ('TYPE %TXTFile%') DO CALL :ParseINI "%%A"

 @echo Finished Reading %INIFile% 
  
 GOTO End 
  
 :Syntax 
 @ECHO Listscheduled <serverslist.txt> 
 ECHO. 
 pause 
  
  
 :End 
 @echo Command Completed 
 @echo Opening %logifle% 
 pause 
 notepad %logfile% 
 @REM Clean Variables 
 ENDLOCAL 
 set SERVERNAME= 
 set logfile= 
 rem exit 
  
 ::===== Go thru .TXT and set each line to a variable and execute; === 
 :ParseINI 
 SET SERVERNAME="%~1" 
 ::Clean the quotes from the servername 
 SET SERVERNAME=%SERVERNAME:"=% 
 rem IF "%SERVERNAME%"=="EOF" GOTO Run2 
 :: Store line in variable 
  
 ECHO Checking : %SERVERNAME% 

@REM RUNS THE COMMAND  
 @echo %SERVERNAME% >> %logfile% 
 SCHTASKS /query /s %SERVERNAME% >> %logfile% 
 @echo. >> %logfile% 
 @echo. >> %logfile% 

Open in new window


I think the site was:  felipeferreira.net  I am not able to get to it from here though.
0
 
Jerry SeinfieldAuthor Commented:
Hi Zindel1

What would be the final power shell script to export the scheduled tasks?
0
 
SeanSystem EngineerCommented:
$sch = New-Object -ComObject("Schedule.Service")
$sch.Connect("remotehost")
$tasks = $sch.GetFolder("\").GetTasks(0)
$outfile_temp = "C:\Temp\tasks\{0}.xml"
$tasks | %{
$xml = $_.Xml
$task_name = $_.Name
$outfile = $outfile_temp -f $task_name
$xml | Out-File $outfile
}
0
 
Jerry SeinfieldAuthor Commented:
Hi Zindel1

I ran the script and showed the errors on the attached file

The script created the XML file but returned nothing[1kb blank file]

Any ideas?
taskserrorscreen.png
ExportScheduledTasks.txt
0
 
Steven CarnahanNetwork ManagerCommented:
Did you change "remotehost" in the line   $sch.Connect("remotehost") to the name of the server?
0
 
Jerry SeinfieldAuthor Commented:
I just changed the remote host in the line, and ran again with no luck. I got no errors after running the script, however the xml was not generated

Any ideas?
0
 
SeanSystem EngineerCommented:
Why not just export them from the task scheduler by right clicking the task a hitting export.
0
 
Jerry SeinfieldAuthor Commented:
Can I export all tasks at same time? or should I export one by one?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.