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 browserStart from a common task
One command per line: show the task in full, its last run and result, run it now, and delete it (the last line). Each line works in Command Prompt and PowerShell except Get-ScheduledTaskInfo, which is PowerShell only.
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
- Start from a common task, or fill in the name and the Task Scheduler folder.
- 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.
- Pick the trigger and, for time-based triggers, an optional repetition every N minutes.
- 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.
- 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, and what the builder does about it
| Trap | What happens | What the builder does |
|---|---|---|
| A .ps1 file set as the program | Task 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 directory | The 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 letters | Drive 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 command | A 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 long | schtasks /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 build | New-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
Frequently asked questions
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.
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.
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.
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.
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.
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.
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
Example 1: 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.
Example 2: 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.
Example 3: 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.
Useful links
- schtasks create reference (Microsoft Learn)
- Register-ScheduledTask (Microsoft Learn)
- New-ScheduledTaskTrigger (Microsoft Learn)
Other tools
- ROBOCOPY Command builder: build the copy job the task will run
- Event Log Analyzer: understand the event that should trigger the task
- All system tools
Related guides
- PowerShell scripts in Windows Task Scheduler: why they fail and how to fix it: every failure case above, with the fix.
- schtasks in Windows: create, query and audit scheduled tasks from CMD: the command in depth, including auditing existing tasks.
- How to backup files with ROBOCOPY: the backup job most nightly tasks run.
- How to read Windows Event Logs with PowerShell (Get-WinEvent): find the event ID an event trigger should wait for.
- Windows Scheduled Tasks Cheat Sheet: the schtasks and ScheduledTasks commands on one printable page.