Introduction
Scheduling scripts lets your computer run tasks automatically at set times. This saves you from doing repetitive work manually.
Jump into concepts and practice - no test required
Scheduling scripts lets your computer run tasks automatically at set times. This saves you from doing repetitive work manually.
schtasks /create /tn "TaskName" /tr "powershell.exe -File C:\Path\To\Script.ps1" /sc schedule_type /st HH:mm
/tn is the task name you choose.
/tr is the command to run your script.
schtasks /create /tn "DailyBackup" /tr "powershell.exe -File C:\Scripts\backup.ps1" /sc daily /st 23:00
schtasks /create /tn "WeeklyCleanup" /tr "powershell.exe -File C:\Scripts\cleanup.ps1" /sc weekly /d MON /st 02:00
This simple PowerShell script prints a message. You can schedule it with Task Scheduler to see it run automatically.
Write-Output "Hello! This script runs on schedule."Make sure your script path is correct and accessible.
Use 24-hour time format for scheduling (e.g., 14:30 for 2:30 PM).
Run Task Scheduler as administrator to create tasks.
Task Scheduler runs scripts automatically at set times.
Use schtasks /create with task name, script path, schedule, and start time.
Scheduling saves time and avoids forgetting important tasks.
schtasks?/create option is used to create a new scheduled task.schtasks /query /tn "BackupTask"
/query option lists information about scheduled tasks./tn "BackupTask" filters the query to show only that task's details.schtasks /create /tn "DailyReport" /tr "powershell.exe C:\Scripts\report.ps1" /sc daily /st 09:00
-File before the script path to run it properly.-File, PowerShell does not know to execute the script file, so the task runs but does nothing.schtasks command correctly sets this up?/sc weekly option schedules tasks weekly on specified days./d MON,FRI to run on Monday and Friday, and /st 18:00 for 6 PM start time.