This article explains how to manage the Windows Task Scheduler by using the command-line tool schtasks.exe , which is available by default on Windows Server and Windows client systems.
All examples assume execution from PowerShell , and line continuation is consistently written with the backtick (`) character.
Variable name Example Description <<SERVER_NAME>>WSRV2025Target server name <<ADMIN_USER>>AdministratorExecution account <<TASK_NAME>>DailyTempCleanupTask name <<SCRIPT_PATH>>C:\Maintenance\cleanup_temp.ps1Script to execute <<LOG_PATH>>C:\Maintenance\LogsLog folder <<BACKUP_PATH>>C:\Maintenance\BackupsEvent log backup destination
All commands in this article are designed to be run from PowerShell .
PowerShell: backtick (`)
CMD: caret (^)
Example (for PowerShell):
/ TR " powershell.exe -File example.ps1 "
The Microsoft-Windows-TaskScheduler/Operational channel may be disabled by default.
Enable it for troubleshooting and detailed history:
wevtutil sl Microsoft - Windows - TaskScheduler / Operational / e:true
Subcommand Purpose /CreateCreate a new task /DeleteDelete a task /QueryList tasks, show details, export XML /ChangeChange task settings /RunRun a task immediately /EndStop a running task /ShowSidShow the SID of the run-as account
/ TR " <<COMMAND_TO_RUN>> " `
Option Description /SCSchedule type (DAILY / WEEKLY / MONTHLY / ONLOGON / ONEVENT) /MOModifier (interval or position) /ST HH:mmStart time /DRun day (1–31 or MON/TUE…) /RURun-as user /RPPassword (* for interactive input) /RL HIGHESTRun with highest privileges /FForce overwrite of existing task
About /MO (modifier)
Parameter that refines the frequency or position of the schedule.
Examples:
“Every 3 hours” → /SC HOURLY /MO 3
“Every 2 weeks” → /SC WEEKLY /MO 2
“Second Wednesday of every month” → /SC MONTHLY /MO SECOND /D WED
“Event-triggered task” → /SC ONEVENT /MO [XPath]
/SCDescription DAILY Every day WEEKLY Every week MONTHLY Every month ONCE One-time execution ONSTART At system startup ONLOGON At user logon ONIDLE When the system is idle ONEVENT On event log trigger
/ TR " powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Maintenance\cleanup_temp.ps1 -DaysToKeep 7 -LogPath <<LOG_PATH>> " `
/ TR " powershell.exe -File C:\Scripts\logon_audit.ps1 " `
/ TR " powershell.exe -File C:\Scripts\startup_init.ps1 " `
/ MO " *[System/EventID=101] " `
/ TR " powershell.exe -File C:\Scripts\event_handler.ps1 " `
/ TR " powershell.exe -File script.ps1 " `
/ TN " SecondWednesdayTask " `
/ TR " powershell.exe -File task.ps1 " `
/ TR " powershell.exe -File script.ps1 " `
/ TR " powershell.exe -File script.ps1 " `
Option Description /FO TABLEOutput as a table /FO LISTOutput as key-value list /VInclude detailed information (triggers, actions, etc.) /TN "<<TASK_NAME>>"Show only the specified task
schtasks.exe / Query / FO TABLE
schtasks.exe / Query / FO LIST / V
schtasks.exe / Query / TN " <<TASK_NAME>> " / FO LIST / V
Option Description /TNTarget task name /RUChange run-as user /RP *Enter new password interactively /TRReplace the command to be executed /ENABLE /DISABLEEnable / disable the task
Note: /Change cannot change trigger definitions such as /SC, /MO, /D, /M.
If you need to change the schedule itself, it is safer to /Delete the task and recreate it with /Create.
/ TR " powershell.exe -File <<SCRIPT_PATH>> -LogPath <<LOG_PATH>> "
schtasks.exe / Change / TN " <<TASK_NAME>> " / ENABLE
schtasks.exe / Change / TN " <<TASK_NAME>> " / DISABLE
Option Description /RunRun the task immediately /IIgnore schedule constraints (start/end date) /EndStop a running task /TNTarget task name
schtasks.exe / Run / TN " <<TASK_NAME>> "
schtasks.exe / Run / TN " <<TASK_NAME>> " / I
schtasks.exe /End / TN " <<TASK_NAME>> "
Option Description /XML fileCreate a task from an XML definition /RUOverride the run-as account /RP *Enter the password interactively
/ XML " C:\TaskTemplates\<<TASK_NAME>>.xml " `
Option Description /XML ONEExport the task definition as a single XML block > fileRedirect the output to a file
> C:\TaskTemplates\ << TASK_NAME >> .xml
Option Description /DeleteDelete mode /TNTarget task name /FForce delete without prompting
schtasks.exe / Delete / TN " <<TASK_NAME>> " / F
Option Description /ShowSidShow the SID associated with the run-as user /TNTarget task name
schtasks.exe / ShowSid / TN " <<TASK_NAME>> "
Option Description /S "<<SERVER_NAME>>"Remote server name /UUser for the remote connection /P *Password for the remote user (* for interactive input) Others Same task definition options as for local tasks
/ TR " powershell.exe -File <<SCRIPT_PATH>> " `
By using schtasks.exe , you can tightly integrate Task Scheduler into server build procedures and automation workflows.
Combining /SC and /MO allows you to express flexible schedules (daily, weekly, monthly, nth weekday, last day of month, and more).
Triggers such as ONLOGON, ONSTART and ONEVENT enable event-driven automation (logon, startup, log events).
With /Query /XML and /Create /XML, you can export and re-import task definitions as reusable XML templates.
The /Change, /Run, /End, /Delete and /ShowSid subcommands cover the main life-cycle operations for scheduled tasks.
By adding /S /U /P, you can roll out identical task definitions to multiple remote servers, supporting large-scale automation scenarios.