PowerShell: Running PowerShell Scripts as Scheduled Task

Schtasks.exe – Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task.

If you have jobs that need to execute regularly, you can manage them with a PowerShell script and make it a scheduled task:


To create a scheduled task do.

schtasks /CREATE /TN CheckHealthScript /TR "powershell.exe -noprofile -executionpolicy Unrestricted -file %public%\checkhealth.ps1" /IT /RL HIGHEST /SC DAILY

To get a list of scheduled tasks / enumerate scheduled tasks do:

schtasks /query


Running PowerShell Scripts as Scheduled Task

About Scheduled Tasks on MSDN

About Scheduled Tasks on Technet


Script to enumerate / list scheduled tasks on a list of servers..

$Version="v8.4.28 Aaron Dodd"
$Description="Generate CSV of scheduled tasks in the environment"

# Settings / Variables
If (Test-Path "QueryScheduledTasks.config") {
$cfg=[xml](get-content "QueryScheduledTasks.config")
} Else {
Write-Host "!! ERROR !! - Config file not found"
Write-Host "A file with the same name as this script, ending in .config, must exist in the same directory as this script."

$ServerList = Import-Csv $cfg.configuration.ServerList.name
$TempReport=$TempDir + "\temp.csv"

# Process tasks
ForEach ($Server in $ServerList) {
schtasks /QUERY /S $Server.Name /FO CSV /V > $TempReport
$TempCsv += Import-Csv $TempReport
Remove-Item $TempReport
$TempCsv | Export-Csv $FinalReport -notype

found here => http://blog.geekpoet.net/2008/04/powershell-script-to-report-on-all.html