# On a Schedule

Run scripts without being there, and make backups that work.

Updated: November 10, 2026

## [Scheduling](https://www.ask-codey.com/courses/powershell-in-depth/topics/powershell-scheduling)

1. [Scheduled Tasks](https://www.ask-codey.com/lessons/powershell-scheduled-tasks) (Journeyman): A scheduled task is Windows' alarm clock for programs, a trigger that says when and an action that says what to run, built with New-ScheduledTaskTrigger and New-ScheduledTaskAction, handed to Task Scheduler with Register-ScheduledTask, and checked with Get-ScheduledTask.
2. [Scripts That Run Without You](https://www.ask-codey.com/lessons/powershell-unattended-scripts) (Freelancer): A script run by a scheduled task has nobody to answer its questions and doesn't start in its own folder, so it takes parameters instead of asking, builds its paths from $PSScriptRoot, leaves a dated log and a Start-Transcript recording, ends with an honest exit code, and runs as the account the task names.

## [Backups](https://www.ask-codey.com/courses/powershell-in-depth/topics/powershell-backups)

1. [Backups That Work: \`robocopy\`](https://www.ask-codey.com/lessons/powershell-robocopy) (Journeyman): robocopy, the copying program that comes with Windows, copies a folder and after that only what changed, mirrors it with /MIR (which deletes from the backup too), rehearses with /L, and ends with an exit code where anything below 8 means success.

## [Exercise: Back Up While You Sleep](https://www.ask-codey.com/courses/powershell-in-depth/topics/exercise-powershell-back-up-while-you-sleep)

1. [Exercise: Back Up While You Sleep](https://www.ask-codey.com/lessons/exercise-powershell-back-up-while-you-sleep) (Journeyman): Turn a backup script that only works at the keyboard into one a scheduled task can run every evening at 6 PM, with no questions, full paths, a dated log and a transcript, a robocopy mirror that never mirrors an empty folder and can rehearse, and an honest exit code, then build the task that runs it, while a Pester check runs your script the way the task would.

Source: https://www.ask-codey.com/courses/powershell-in-depth/chapters/powershell-on-a-schedule
