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?
Hoelli
  • 43
  • 2
  • 8

1 Answers1

3

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.

Mer
  • 991
  • 4
  • 9