liveBook · Manning

Task Scheduler

As explained in Practical Automation with PowerShell: Effective scripting from the console to the cloud

Task Scheduler is the Windows service and management facility for scheduling and running programs or scripts.

Task Scheduler is a built-in Windows facility for running PowerShell scripts on a schedule. It is easy to deploy and widely used, but lacks a central console, so task design, access, and maintenance require deliberate administration. section 3.2.1

Design scheduled tasks around these operational requirements:

  • Run unattended by selecting an execution mode that does not require a user to remain logged on. section 3.2.1
  • Check permissions for both the script file and every resource the script accesses. section 3.2.1
  • Use a service account for scripts stored on network shares; never use a personal account whose password changes or account lockouts can interrupt the task. section 3.2.1
  • Install required custom modules in a PowerShell module path that the scheduled process can access. section 3.2.1
  • Separate watcher scripts, which monitor events, from action scripts, which perform the resulting work; define execution limits and graceful termination. section 3.5

Scheduled log cleanup

A task can invoke a reusable cleanup script with local or network paths, an archive prefix, and a retention period. The task identity must be able to read the script and access the log and archive locations. section 3.2.1

-File "C:\Scripts\Invoke-LogFileCleanup.ps1" -LogPath "L:\Logs\" -ZipPath "L:
\Archives\" -ZipPrefix "LogArchive-" -NumberOfDays 30

Example PowerShell arguments for invoking a log-file cleanup script from a scheduled task. section 3.2.1

How Practical Automation with PowerShell: Effective scripting from the console to the cloud covers it

How deep it goes
Explains permissions, service accounts, module paths, unattended execution, and watcher design, but not centralized administration or full task creation steps.
Examples
Uses a log-cleanup script with archive paths, a filename prefix, and a thirty-day retention argument.
What it assumes
Assumes familiarity with Windows Task Scheduler and PowerShell, while reinforcing permissions, module paths, service accounts, and execution planning.
What you can do after
Operate/configure unattended script execution with appropriate identities, resource permissions, module installation, monitoring boundaries, and termination behavior.
How it connects
Connects scheduled tasks with PowerShell scripts, custom modules, service accounts, network shares, and Cron.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Practical Automation with PowerShell: Effective scripting from the console to the cloud. The section links point to the parts of the book it draws on.