Creating Scheduled Tasks From XML

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

In a previous tip, we showed how you can export a scheduled task to an XML file. Now, it's time to see how you can re-import that XML file to re-create the scheduled task. Before you can use this tip, you need an XML definition for a task. Check out the Export-ScheduledTask function in our previous tip to create that file.

You can use this technique to clone a scheduled task to multiple machines, or you can first export a scheduled task to XML, then adjust all the advanced settings inside the XML file, and finally reimport the scheduled task from the adjusted XML file.

function Import-ScheduledTask {



    if ($ComputerName -ne $null) {
      $option = "/S $ComputerName"
    } else {
      $option = ''  
    schtasks /CREATE /TN $jobname /XML $path $option

Twitter This Tip! ReTweet this Tip!

Posted Apr 17 2012, 06:00 AM by ps1
Copyright 2012 All rights reserved.