brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Get-ScheduledTaskInfo shows when a scheduled task last ran

Troubleshooting
~/tips/tip-windows-get-scheduledtaskinfo-last-result

Get-ScheduledTaskInfo -TaskName "\Sample\SchedTask01"

Gets run-time information for a scheduled task, so you can see whether it ran.

A scheduled task that never seems to do anything is a classic. Before digging into its actions, check whether it runs at all. Task Scheduler shows this in a tab. PowerShell shows it in one line.

Get-ScheduledTaskInfo -TaskName "\Sample\SchedTask01"

The cmdlet gets the last run-time information for a task. That is a separate object from the task definition, which is why Get-ScheduledTask alone does not tell you whether it ran. The documented pipeline form covers a whole folder of tasks:

Get-ScheduledTask -TaskPath "\Sample\" | Get-ScheduledTaskInfo

The documentation does not list the properties of the returned object, so look at them yourself once, with | Format-List *. Check there for the fields about the last run and its result, since the page does not name them.

Task names matter here. -TaskPath needs the leading and trailing backslash for a full path, and \ alone is the root folder. If you leave the path out, the cmdlet uses the root folder, so a task in a subfolder is not found by name alone. The documentation also notes that -TaskPath accepts * as a wildcard.

Pair it with Start-ScheduledTask, which is linked from the same page, to run a task by hand and then check the info again.

None of this was run on a live Windows machine here. It follows the Microsoft documentation.

Further reading: Get-ScheduledTaskInfo

More Troubleshooting tips Get-NetTCPConnection -State Listen modinfo -p usb_storage ps -o pid,lstart,etime,cmd -p 1234 sudo lsof -nP -p 1234 fc-match Helvetica All Troubleshooting tips (22) All topics

Link