Windows Server · Windows  ·  medium  ·  Exchange, WSUS, PKI & RDS

A scheduled task reports success but does nothing, or fails 0x1

The task ran and the program inside it failed, or the task never ran because of how it is configured to run.

What you see

The Last Run Result column shows a code, or 0x0 with nothing having happened. Running the same command by hand works perfectly.

What is actually wrong

0x1 is the program's own exit code. 0x2147942402 is file not found. 0x41303 means it has never run. 0x800710E0 is the operator refusal that comes from the power conditions.

Codes and articles

0x10x413030x21479424020x800710E0The operator or administrator has refused the requestLast Run Result

Fixes (2)

Make the task's environment match the one you tested in
Elevated PowerShell30 minutesmedium riskreversible

The task runs and the program fails.

  1. Read the task's configuration.

    PowerShell
    Get-ScheduledTask -TaskName 'Nightly Export' | Select-Object -ExpandProperty ActionsGet-ScheduledTask -TaskName 'Nightly Export' | Select-Object -ExpandProperty Principal
  2. Set the Start in field. A script that uses relative paths fails with no working directory set, which is the single most common cause of a task that works by hand and not on schedule.

    PowerShell
    $a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -File C:\Scripts\export.ps1' -WorkingDirectory 'C:\Scripts'Set-ScheduledTask -TaskName 'Nightly Export' -Action $a

    Without it, the task starts in C:\Windows\System32, so every relative path in the script points somewhere unexpected. The script does not error in a way that is obvious — it writes its output into System32 or fails to find its input.

  3. Check the account it runs as has the rights it needs — including Log on as a batch job, and access to any network share.

    PowerShell
    Get-ScheduledTask -TaskName 'Nightly Export' | Select-Object -ExpandProperty Principal | Format-List UserId,LogonType,RunLevel
  4. A mapped drive does not exist for a task running as another account. Use UNC paths.

    Drive mappings are per-session. A task running under a service account in session 0 has none of them, and the script fails on the first reference to Z:.

  5. Capture the output so the failure is visible next time.

    PowerShell
    $a = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -File C:\Scripts\export.ps1 *> C:\Logs\export.log'Set-ScheduledTask -TaskName 'Nightly Export' -Action $a
  6. Read the task's own history for what it thought happened.

    PowerShell
    Get-WinEvent -LogName 'Microsoft-Windows-TaskScheduler/Operational' -MaxEvents 60 | Where-Object Message -like '*Nightly Export*' | Format-Table TimeCreated,Id,Message -Wrap
Confirm it workedThe task returns 0x0 and its output file shows the work was done.
PowerShell
Start-ScheduledTask -TaskName 'Nightly Export'Start-Sleep 30Get-ScheduledTaskInfo -TaskName 'Nightly Export' | Format-List LastRunTime,LastTaskResult,NextRunTime
If you need to undo itSet-ScheduledTask with the previous action definition.
Make the task actually start
Elevated PowerShell25 minuteslow riskreversible

It never runs, or is refused.

  1. Check the trigger and the conditions.

    PowerShell
    Get-ScheduledTask -TaskName 'Nightly Export' | Select-Object -ExpandProperty TriggersGet-ScheduledTask -TaskName 'Nightly Export' | Select-Object -ExpandProperty Settings | Format-List DisallowStartIfOnBatteries,StopIfGoingOnBatteries,RunOnlyIfNetworkAvailable,RunOnlyIfIdle,WakeToRun
  2. 0x800710E0 is the operator refusal, and on a laptop it is almost always the battery condition.

    PowerShell
    $s = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailableSet-ScheduledTask -TaskName 'Nightly Export' -Settings $s

    The default settings refuse to start on battery and stop the task if the machine unplugs. On a laptop or a virtual machine that reports a battery, that means it never runs and the message gives no hint why.

  3. Set Run whether the user is logged on or not, so it runs without a session.

    PowerShell
    $p = New-ScheduledTaskPrincipal -UserId 'EXAMPLE\svc_task' -LogonType Password -RunLevel HighestSet-ScheduledTask -TaskName 'Nightly Export' -Principal $p -User 'EXAMPLE\svc_task' -Password (Read-Host -AsSecureString | ConvertFrom-SecureString -AsPlainText)
  4. Enable Start when available, so a task missed while the machine was off runs at the next opportunity.

  5. Check the task is enabled and the trigger date has not passed.

    PowerShell
    Get-ScheduledTask -TaskName 'Nightly Export' | Format-List TaskName,StateGet-ScheduledTaskInfo -TaskName 'Nightly Export' | Format-List NextRunTime,LastRunTime,NumberOfMissedRuns
Confirm it workedNextRunTime is populated and the task runs at the scheduled time.
PowerShell
Get-ScheduledTaskInfo -TaskName 'Nightly Export' | Format-List LastRunTime,LastTaskResult,NextRunTime,NumberOfMissedRuns
If you need to undo itSet-ScheduledTask with the previous settings object.

Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.