PowerShell Genie

Review scheduled tasks with nonzero results

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Find scheduled tasks with nonzero result codes and distinguish action failures from Task Scheduler status codes.

Example reviewed 1 October 2026 · Illustrative output · Not a live system check

The script

Get-ScheduledTask -ErrorAction Stop |
    Get-ScheduledTaskInfo -ErrorAction Stop |
    Where-Object LastTaskResult -ne 0 |
    Select-Object TaskName, TaskPath, LastRunTime, LastTaskResult

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output

    Fictional reference snapshot · 03 October 2026, 09:00 UTC. This is an example result, not a check of your systems.

    TaskName       TaskPath  LastRunTime           LastTaskResult
    --------       --------  -----------           --------------
    NightlyReport  \Demo\   03/10/2026 02:00:00    1
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-ScheduledTask -ErrorAction Stop | Get-ScheduledTaskInfo -ErrorAction Stop | Where-Object LastTaskResult -ne 0 | Select-Object TaskName, TaskPath, LastRunTime, LastTaskResult
    1. Stage 1Get-ScheduledTask-ErrorAction
    2. Stage 2Get-ScheduledTaskInfo-ErrorAction
    3. Stage 3Where-Object-ne
    4. Stage 4Select-ObjectPositional values or no named parameters

      Illustrative output

      This example shows the expected shape for fictional data. Your values and formatting will differ.

      TaskName  TaskPath  LastRunTime          LastTaskResult
      Backup    \         2026-09-30 23:00:00  1

      How it works

      Get-ScheduledTaskInfo returns runtime information. The filter excludes zero. A nonzero value needs interpretation: some codes describe scheduler state, while others come from the action executable. Do not label every returned row as a failed business task.

      Before you run it

      Use Windows with the ScheduledTasks module and permissions to read the relevant tasks. Query a specific TaskPath for a focused investigation. Check the configured executable, task identity and working directory.

      Check the result

      Compare LastRunTime, action logs and Task Scheduler history for the same attempt. Interpret the code in its proper context and verify that the expected report or side effect actually occurred.

      If nothing is returned

      No returned task had a nonzero result at query time. That does not establish that all tasks ran recently or produced their intended output.

      Practise the underlying skill

      Try a related exercise →

      Read the primary Microsoft documentation

      Genie guideReview scheduled tasks with nonzero results

      Find scheduled tasks with nonzero result codes and distinguish action failures from Task Scheduler status codes.