Scheduled task builder: schtasks and Register-ScheduledTask

Build schtasks and PowerShell scheduled task commands, with the traps that make tasks fail flagged

Build a scheduled task as a schtasks /create line and as Register-ScheduledTask PowerShell, from the same form. The builder writes the powershell.exe -File wrapper for you, quotes paths correctly, never puts a password in the command, and flags the settings that make tasks fail silently: a missing working directory, a mapped drive under SYSTEM, a command line that is too long, a date in the wrong regional format.

Build schtasks and Register-ScheduledTask commands, with the traps that make tasks fail flagged.

Runs in your browser
Presets
Task
Action
Trigger
days
On
minutes
Run as
More options
every minutes for hours

Run the commands in an elevated window. Nothing here runs anything: the tool only builds text, and it never asks for a password.

How to use

  1. Start from a common task, or fill in the name and the Task Scheduler folder.
  2. Pick the action: a Windows PowerShell 5.1 script, a PowerShell 7 script, a batch file or a program. Give the path and Start in, the folder the script expects to run from.
  3. Pick the trigger and, for time-based triggers, an optional repetition every N minutes.
  4. Pick who it runs as. SYSTEM for machine jobs, a named account or a gMSA for jobs that need network access with a domain identity.
  5. Read the warnings, then copy the Command Prompt line or the PowerShell block. Use the check block to confirm the task and run it once by hand.

Why scheduled tasks fail

TrapWhat happensWhat the builder does
A .ps1 file set as the programTask Scheduler does not run a script file as a program: it opens it with the default app, often Notepad, or fails.Wraps it: powershell.exe -NoProfile -ExecutionPolicy Bypass -File "...", or pwsh.exe for PowerShell 7.
No working directoryThe script runs in System32, so relative paths and .\ references break.Sets Start in in PowerShell. schtasks has no switch for it: the builder says so, and offers the PowerShell form.
Mapped drive lettersDrive letters mapped in your session do not exist for SYSTEM or for a task that runs without a logged-on user.Warns and suggests the UNC path. Under SYSTEM the share must also allow the computer account.
Password in the commandA password typed into /rp or -Password ends up in shell history and scripts.Never writes one. schtasks prompts for it; PowerShell uses Get-Credential, or a gMSA with no password at all.
Command line too longschtasks /tr refuses a run string longer than 261 characters.Counts it and switches you to the PowerShell form when it is too long.
Start date format/sd follows the regional settings of the machine; an ISO date is refused on Italian settings, for example.Warns when a start date is set. The PowerShell form is not affected.
Triggers PowerShell cannot buildNew-ScheduledTaskTrigger has no monthly, idle or event trigger.Uses schtasks for those, and adds a Set-ScheduledTask step when the task also needs Start in or a gMSA.

FAQ

schtasks or Register-ScheduledTask: which one should I use?

Use PowerShell when you can: it sets the working directory, handles a gMSA and a logon trigger for one user, and has no 261-character limit on the command line. Use schtasks for monthly, idle and event triggers, which the PowerShell cmdlet cannot create, and on machines where you only have a Command Prompt. The builder shows both and tells you when one of them cannot express the task.

The task says it ran, but the script did nothing. Why?

Usually one of three things: no working directory, so the script looks for its files in System32; a mapped drive that does not exist in the task’s session; or an execution policy block. Check the task’s Last Run Result with schtasks /query /tn "\Folder\Task" /v /fo list, then run the exact command line by hand as the same account. The troubleshooting guide goes through each case.

Should the task run as SYSTEM, a user or a gMSA?

SYSTEM for local maintenance: it needs no password and has full rights on the machine, but on the network it is the computer account. A named domain account when the job needs a user identity on file shares or databases, at the cost of a password to manage. A group managed service account (gMSA) gives the domain identity without any password to store or rotate; the builder creates it with PowerShell, following Microsoft’s example.

Where is pwsh.exe for PowerShell 7?

The MSI installer puts it in C:\Program Files\PowerShell\7\pwsh.exe. Recent versions installed with winget use the MSIX package, which lives in another folder, so check with (Get-Command pwsh).Source on the target machine before you rely on the path.

Why does my task not start on a laptop?

Tasks created by schtasks or Register-ScheduledTask default to “start only on AC power”. On a laptop on battery the trigger fires and nothing runs. Clear that condition in the task’s Conditions tab, or with New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries passed to Register-ScheduledTask -Settings.

How do I run a task every 15 minutes during working hours?

Use a daily or weekly trigger at the start of the day with a repetition interval of 15 minutes for the length of the working day. In schtasks that is /ri 15 /du 09:00; the builder produces the same repetition in PowerShell. The cleanup example below does exactly this on weekdays.

How do I delete or change a task I created?

schtasks /delete /tn "\Folder\Task" /f removes it; the builder’s check block includes the line. To change a task, rebuild it with Overwrite if it exists ticked (/f in schtasks, -Force in PowerShell), which replaces it in one step.

Practical examples

Nightly backup script as SYSTEM

C:\Scripts\backup.ps1 every day at 02:00, run from C:\Scripts, in the \Admin\ folder of Task Scheduler. The schtasks line and the PowerShell block both come out; only PowerShell keeps the working directory.

Open in the builder →

Cleanup every 15 minutes in working hours

A batch file on weekdays from 08:00, repeated every 15 minutes, as a service account whose password is asked for when the command runs.

Open in the builder →

React to an account lockout

Event ID 4740 in the Security log starts an alert script, run as a gMSA so no password is stored anywhere. The event trigger comes from schtasks, the gMSA from a Set-ScheduledTask step.

Open in the builder →

Related guides

Other tools