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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SeanSystem EngineerCommented:
SeanSystem EngineerCommented:
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 
 del list_scheduled.TXT /q 
 set logfile=list_scheduled.TXT 
 :: Read variables from command line 
 SET TXTFile="%~f1" 
 @echo Retriving Scheduled jobs from %TXTFile% please wait... 
 :: 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 
 @ECHO Listscheduled <serverslist.txt> 
 @echo Command Completed 
 @echo Opening %logifle% 
 notepad %logfile% 
 @REM Clean Variables 
 set logfile= 
 rem exit 
 ::===== Go thru .TXT and set each line to a variable and execute; === 
 ::Clean the quotes from the servername 
 rem IF "%SERVERNAME%"=="EOF" GOTO Run2 
 :: Store line in variable 
 ECHO Checking : %SERVERNAME% 

 @echo %SERVERNAME% >> %logfile% 
 SCHTASKS /query /s %SERVERNAME% >> %logfile% 
 @echo. >> %logfile% 
 @echo. >> %logfile% 

Open in new window

I think the site was:  I am not able to get to it from here though.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Jerry SeinfieldAuthor Commented:
Hi Zindel1

What would be the final power shell script to export the scheduled tasks?
SeanSystem EngineerCommented:
$sch = New-Object -ComObject("Schedule.Service")
$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
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?
Steven CarnahanNetwork ManagerCommented:
Did you change "remotehost" in the line   $sch.Connect("remotehost") to the name of the server?
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?
SeanSystem EngineerCommented:
Why not just export them from the task scheduler by right clicking the task a hitting export.
Jerry SeinfieldAuthor Commented:
Can I export all tasks at same time? or should I export one by one?
SeanSystem EngineerCommented:
to do it through the GUI you need to do them one at a time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.