Skip to content

How to Create a Scheduled Application Maintenance Task Print

  • 0

Applies to: Windows Server 2019, Windows Server 2022, and Windows Server 2025.

Task Scheduler can run a signed maintenance script under a controlled identity with a predictable trigger, timeout, and audit trail.

Prerequisites

  • A tested and signed PowerShell maintenance script.
  • A dedicated task identity with only required file and application permissions.
  • An approved maintenance schedule and rollback plan.

Configuration procedure

  1. Place the script in an administrator-controlled directory.
  2. Create an action that starts PowerShell with NoProfile and the full script path.
  3. Create a trigger outside peak usage.
  4. Set a finite execution limit and configure the task not to start a second instance.
  5. Register the task with the least required run level and test it manually.

PowerShell commands

$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy AllSigned -File C:\Ops\AppMaintenance.ps1"
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 3am
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 1) -MultipleInstances IgnoreNew
Register-ScheduledTask -TaskName "Application Maintenance" -Action $action -Trigger $trigger -Settings $settings -Description "Approved weekly application maintenance"

Verification

Start the task manually, confirm LastTaskResult is 0, review the script log, and validate application availability.

Rollback

Disable or unregister the task and restore the previous application state from the documented script rollback procedure.

Security and operations

  • Do not embed credentials in task arguments.
  • Restrict write access to the script directory.
  • Forward Task Scheduler operational events to centralized monitoring.

Related resources

Build your Canadian Windows VPS environment with networkmanager.info. Consult the Microsoft Windows Server documentation before production deployment.


Was this answer helpful?

« Back