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
- name,
- status,
- triggers,
- next run time,
- last run time,
- last run result,
- author,
- created.
I can print out the information about the name, next run time, and last run time, but the rest won't 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.
Below is a screenshot with what i am looking for and what fields arent printing out data:
$Tasks | Get-Member
what do you get?$tasks
contains. It doesn't have all that you want to output:Name
,Path
,State
,Enabled
,LastRunTime
,LastTaskResult
,NumberOfMissedRuns
,NextRunTime
,Definition
,Xml
.get.Triggers
to pull the triggers for that task?