NTS: Get a list of windows scheduled tasks
I've been working on support for a while, and one of my tasks involved checking the set up of a windows scheduled task. I wanted to script out the scheduled tasks, so I could review them in an easier manner than having to use the GUI and navigating through them all.The dos command schtasks holds the key. So, after opening a command prompt, the command schtasks /queryproduces a list of all the scheduled tasks, including Task Name, Next Run Time and Status.
I wanted a bit more detail, specifically the path of what was scheduled, so I used the command schtasks /query /v /fo LISTwhich produces a detailed list of all tasks. This includes additional information such as the task being run, schedule information etc
Finally, to get the output in a CSV format I used schtasks /query /v /fo CSVThis produces the same quantity of detailed information as LIST.So, finally, by piping the output schtasks /query /v /fo CSV > tasks.csvI get a tasks.csv file which I can open in Excel and review for correctness and completeness.
I wanted a bit more detail, specifically the path of what was scheduled, so I used the command schtasks /query /v /fo LISTwhich produces a detailed list of all tasks. This includes additional information such as the task being run, schedule information etc
Finally, to get the output in a CSV format I used schtasks /query /v /fo CSVThis produces the same quantity of detailed information as LIST.So, finally, by piping the output schtasks /query /v /fo CSV > tasks.csvI get a tasks.csv file which I can open in Excel and review for correctness and completeness.
