How to print out information about Task Scheduler in powershell script?

Posted by Jimboy on Server Fault See other posts from Server Fault or by Jimboy
Published on 2014-06-12T15:06:47Z Indexed on 2014/06/12 15:27 UTC
Read the original article Hit count: 218

I am trying to print out information from the Task Scheduler from the local computer in a powershell script so other users can print out this information as well and not have to access the Task Scheduler. I need the script to print out the name, status, triggers, next run time, last run time, last run result, author and created. I can print out the information about the name, next run time, and last run time, but the rest wont print out when i run the script.

I have already got a little start on my script and got the fields down.

$schedule = new-object -com("Schedule.Service") 
$schedule.connect() 
$tasks = $schedule.getfolder("\").gettasks(0)

$tasks | select Name,Status,Triggers,NextRunTime,LastRunTime,LastRunResult,Author,Created | ft

foreach ($t in $tasks)
{
foreach ($a in $t.Actions)
{
$a.Path
}
}

Any help or suggestions would be appreciated.

© Server Fault or respective owner

Related posts about windows-server-2008

Related posts about windows-server-2012