2

I need to backup Task Scheduler Tasks. These are already grouped into one subfolder within the Task Scheduler. But the only way I found, is to use

schtasks.exe /query /tn "<path>\<taskname>"

With that I have to specify every single task... but these could be different on different machines.

I'm searching for a simple way to use a wildcard. E.g.

schtasks.exe /query /tn "<path>\*"

Is there a way, to

  • not export the whole list? (I really don't care about Microsofts own tasks like \Microsoft\Windows\Wininet\CacheTask)
  • export a whole folder?
2

Use Powershell. On Windows Server 2008 R2 , you can use the following code;

$x = New-Object -ComObject("Schedule.Service") ; $x.Connect() ; $x.GetFolder("\CustomTasks").GetTasks(1) | % {$_.XML | Out-File "C:\temp\$($_.Name).xml"}

This will export all the tasks under "CustomTasks" folder to C:\Temp folder and file names will be "WhateverTheTaskNameIs.xml" .

For Windows Server 2012 and later, you can use Get-ScheduledTask and Export-ScheduledTask cmdlets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.