Output Scheduled Tasks to XML

by Apr 16, 2012

Here's an easy way how you can export and dump a task that you created in "Scheduled Tasks" to XML:

function Export-ScheduledTask {
    param(
        [Parameter(Mandatory=$true)]
        $TaskName,
        
        [Parameter(Mandatory=$true)]
        $XMLFileName
    )
    
    schtasks /QUERY /TN $TaskName /XML | Out-File $XMLFileName
}

Specify the name of a scheduled task and a path to some XML file. If you are not sure what the names of your scheduled tasks are, this is how you can list the names of all scheduled tasks you can access:

PS> schtasks /QUERY

 

Twitter This Tip! ReTweet this Tip!