PowerShell Genie

Get-ScheduledTaskInfo

Use Get-ScheduledTaskInfo to return run history for a scheduled task: last run time, last result and next run time.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — PowerShell module reference

Syntax

1PS> Get-ScheduledTaskInfo [-TaskName] <String> [-TaskPath <String>] [-CimSession <CimSession[]>] [<CommonParameters>]
See the command anatomy

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

Get-ScheduledTaskInfo [-TaskName] <String> [-TaskPath <String>] [-CimSession <CimSession[]>] [<CommonParameters>]
  1. Stage 1Get-ScheduledTaskInfo-TaskName -TaskPath -CimSession

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Get-ScheduledTask -TaskPath \

    1PS> Get-ScheduledTask -TaskPath \ | Get-ScheduledTaskInfo | Select-Object TaskName, LastRunTime, LastTaskResult
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TaskName     LastRunTime            LastTaskResult
    -----------  ---------------------  --------------
    Backup       9/10/2026 10:00:01 PM  0
    Maintenance  9/9/2026 3:00:00 AM    0

    Get-ScheduledTaskInfo -TaskName MyTask

    1PS> Get-ScheduledTaskInfo -TaskName MyTask | Select-Object LastTaskResult, NextRunTime
    Show reference output

    Sample output · fictional data, shaped like the real thing

    LastTaskResult  NextRunTime
    --------------  ---------------------
    0               9/11/2026 10:00:00 PM
    0

    Get-ScheduledTaskInfo -TaskName MyTask (2)

    1PS> Get-ScheduledTaskInfo -TaskName MyTask | ForEach-Object { "0x{0:X}" -f $_.LastTaskResult }
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TaskPath             TaskName     State     LastTaskResult
    -------------------  -----------  --------  --------------
    \                    Backup       Ready     0
    \Microsoft\Windows\  Maintenance  Disabled  0

    Parameters

    Parameter definitions:

    • -TaskName
    • -TaskPath
    • -CimSession

    PowerShell module reference on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-ScheduledTaskInfo when you need to return run history for a scheduled task: last run time, last result and next run time. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: A nonzero LastTaskResult requires decoding the task or process result and inspecting history. Check the action, account and working directory before assuming the scheduler itself failed. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ScheduledTask. Get-ScheduledTask returns task configuration; Get-ScheduledTaskInfo returns runtime information such as LastRunTime and LastTaskResult. An enabled task definition is not evidence of a successful last run. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-ScheduledTaskInfo reference on Microsoft Learn

    Recap

    Get-ScheduledTaskInfo Use Get-ScheduledTaskInfo to return run history for a scheduled task: last run time, last result and next run time.

    Next: Get-Date
    Genie guideGet-ScheduledTaskInfo

    Use Get-ScheduledTaskInfo to return run history for a scheduled task: last run time, last result and next run time. The console below is pre-loaded — run it, then change a value and run it again.