Create a scheduled task in PowerShell by building an action with New-ScheduledTaskAction, a trigger with New-ScheduledTaskTrigger, and saving both with Register-ScheduledTask.
This guide covers running a script on a schedule, triggers and run accounts, changing task settings, listing, starting, disabling, exporting, importing and deleting tasks, and the result codes that explain a task that never ran.

Creating a scheduled task with Windows PowerShell
The ScheduledTasks module ships with Windows 10, Windows 11 and Windows Server, so there is nothing to install. These steps create a task called NightlyCleanup that runs a batch file every day at 3:00 AM.
- Open PowerShell as administrator so the task can be registered for any account and run level.
- Define what the task runs:
$action = New-ScheduledTaskAction -Execute "C:\Scripts\cleanup.cmd". - Define when it runs:
$trigger = New-ScheduledTaskTrigger -Daily -At 3am. - Register the task:
Register-ScheduledTask -TaskName "NightlyCleanup" -Action $action -Trigger $trigger -Description "Daily temp cleanup". - Check that it exists:
Get-ScheduledTask -TaskName "NightlyCleanup". The State column should read Ready.
Without -TaskPath, the task lands in the root folder of the Task Scheduler Library. Add -TaskPath "\Maintenance\" to file it in a folder; the path needs a leading and a trailing backslash. Add -Force to overwrite an existing task of the same name without a prompt.
New-ScheduledTaskTrigger examples: daily, weekly, at startup and at logon
New-ScheduledTaskTrigger has five parameter sets. Pick the row that matches the schedule, assign the result to $trigger, and pass it to Register-ScheduledTask or Set-ScheduledTask.
| Schedule | Trigger command | Notes |
|---|---|---|
| Once at a set time | New-ScheduledTaskTrigger -Once -At 3am |
The only set that accepts -RepetitionInterval and -RepetitionDuration |
| Every 15 minutes for a day | New-ScheduledTaskTrigger -Once -At 8am -RepetitionInterval (New-TimeSpan -Minutes 15) -RepetitionDuration (New-TimeSpan -Days 1) |
The task runs, waits the interval, and runs again until the duration ends |
| Every day | New-ScheduledTaskTrigger -Daily -At 3am |
-DaysInterval 3 makes it every third day |
| Every other Sunday | New-ScheduledTaskTrigger -Weekly -WeeksInterval 2 -DaysOfWeek Sunday -At 3am |
-DaysOfWeek takes several days: Monday,Wednesday,Friday |
| When Windows starts | New-ScheduledTaskTrigger -AtStartup |
Runs at boot, before anyone signs in |
| When a user signs in | New-ScheduledTaskTrigger -AtLogOn |
Add -User "CONTOSO\jsmith" to fire for one account only |
| Spread the load across PCs | Add -RandomDelay (New-TimeSpan -Minutes 30) to any trigger |
Starts at a random point inside the delay window |
There is no monthly parameter set. A monthly schedule needs schtasks.exe, covered further down.
How to run a PowerShell script as a scheduled task
Point the action at powershell.exe and pass the script through -File, which must be the last parameter on the line. Set a working directory, because a task without one starts in %windir%\system32 and relative paths in the script break.
- Save the script, for example
C:\Scripts\Backup.ps1. - Build the action:
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -File "C:\Scripts\Backup.ps1"' -WorkingDirectory "C:\Scripts". - Build the trigger:
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Friday -At 6pm. - Register it:
Register-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" -Action $action -Trigger $trigger. - Test it straight away with
Start-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\".
-NonInteractive makes Read-Host or a confirmation prompt fail with an error instead of hanging the task forever. -ExecutionPolicy here applies to that one session only and leaves the machine's policy in the registry unchanged.
For PowerShell 7, use pwsh.exe as the -Execute value. To keep a window from flashing on the desktop, add -WindowStyle Hidden before -File.
Run a scheduled task with highest privileges or as a service account in PowerShell
By default a task runs as the account that registers it, with limited rights. New-ScheduledTaskPrincipal sets a different account, a group, or elevated rights, and the task then runs whether or not that account is signed in.
| You need the task to | Principal command | What it does |
|---|---|---|
| Run elevated for members of Administrators | New-ScheduledTaskPrincipal -GroupId "BUILTIN\Administrators" -RunLevel Highest |
Runs with the highest privileges for signed-in admins |
| Run as the Local Service account | New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount |
No user password stored; good for background jobs |
| Run as a user without storing a password | New-ScheduledTaskPrincipal -UserId "CONTOSO\svc-reports" -LogonType S4U |
No password saved, but no network shares or encrypted files |
| Run only while the user is signed in | New-ScheduledTaskPrincipal -UserId "CONTOSO\jsmith" -LogonType Interactive |
Runs inside the user's existing desktop session |
| Run as a user who may be signed out, with network access | Register-ScheduledTask ... -User "CONTOSO\svc-reports" -Password "<password>" |
Task Scheduler stores the password with the task |
Pass the principal with Register-ScheduledTask -TaskName "Task01" -Action $action -Trigger $trigger -Principal $principal. A principal takes either a user or a group, never both. For a quick elevated task under the account you type, Register-ScheduledTask also accepts -RunLevel Highest directly.

How to create a monthly scheduled task from PowerShell
New-ScheduledTaskTrigger cannot build a monthly schedule, but schtasks.exe can, and it runs fine from a PowerShell prompt.
schtasks /create /tn "MonthlyReport" /tr "C:\Scripts\report.cmd" /sc monthly /d 15 /st 15:00
schtasks /create /tn "PatchCheck" /tr "C:\Scripts\check.cmd" /sc monthly /mo SECOND /d TUE
schtasks /create /tn "MonthEnd" /tr "C:\Scripts\close.cmd" /sc monthly /mo lastday /m *
Line 1 runs on the 15th of every month at 3:00 PM. Line 2 runs on the second Tuesday of every month. Line 3 runs on the last day of every month; /m * is required with lastday.
You should see: schtasks prints SUCCESS: The scheduled task MonthlyReport has successfully been created. The task then shows up in Get-ScheduledTask like any other.
After schtasks creates the task, every PowerShell cmdlet in this guide can manage it: Set-ScheduledTask to change the action, Export-ScheduledTask to back it up.
Create a scheduled task on a remote computer with PowerShell
Every ScheduledTasks cmdlet takes -CimSession, so the same commands work against another PC without signing in to it. Your account needs admin rights on the remote computer.
- Open a session:
$s = New-CimSession -ComputerName PC01. - Build the action and trigger as usual:
$action = New-ScheduledTaskAction -Execute "C:\Scripts\cleanup.cmd"and$trigger = New-ScheduledTaskTrigger -Daily -At 2am. - Register it on the remote PC:
Register-ScheduledTask -TaskName "NightlyCleanup" -Action $action -Trigger $trigger -CimSession $s. - Check it:
Get-ScheduledTask -TaskName "NightlyCleanup" -CimSession $s. - Close the session when done:
Remove-CimSession $s.
New-CimSession -ComputerName PC01,PC02,PC03 opens sessions to several machines at once, and the register command then creates the task on all of them.
Change scheduled task settings with PowerShell
Set-ScheduledTask rewrites part of an existing task: its trigger, its actions, its settings or its principal. A new trigger replaces the old one, and edits never affect an instance that is already running.
- Change the schedule:
Set-ScheduledTask -TaskName "NightlyCleanup" -Trigger (New-ScheduledTaskTrigger -Daily -At 1am). - Replace the actions with two programs that run in order:
Set-ScheduledTask -TaskName "DeployTools" -Action $act1,$act2. - Build a settings set:
$set = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Hours 1) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 10). - Apply it:
Set-ScheduledTask -TaskName "NightlyCleanup" -Settings $set. - Switch the run account:
Set-ScheduledTask -TaskName "NightlyCleanup" -Principal $principal.
Other switches on New-ScheduledTaskSettingsSet: -WakeToRun wakes the PC first, -MultipleInstances Queue (or Parallel, IgnoreNew) decides what happens if the task fires while a copy is still running, and -Hidden hides the task in the Task Scheduler window. Without -ExecutionTimeLimit, Task Scheduler allows a task three days to finish.

Managing scheduled tasks with PowerShell
Each cmdlet below takes -TaskName and -TaskPath, or a task piped in from Get-ScheduledTask, which is how you act on a whole folder at once.
| To do this | Command |
|---|---|
| List every task on the PC | Get-ScheduledTask |
| List tasks in one folder | Get-ScheduledTask -TaskPath "\Scripts\*" |
| Find tasks by name pattern | Get-ScheduledTask -TaskName "*Backup*" |
| List only running tasks | Get-ScheduledTask | Where-Object State -eq 'Running' |
| Run a task now | Start-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" |
| Stop a running task | Stop-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" |
| Disable a task | Disable-ScheduledTask -TaskName "NightlyCleanup" |
| Disable every task in a folder | Get-ScheduledTask -TaskPath "\Scripts\" | Disable-ScheduledTask |
| Turn a task back on | Enable-ScheduledTask -TaskName "NightlyCleanup" |
| See a task's actions | (Get-ScheduledTask -TaskName "WeeklyBackup").Actions |
| See a task's triggers | (Get-ScheduledTask -TaskName "WeeklyBackup").Triggers |
Start-ScheduledTask returns as soon as the task starts, not when it finishes. The built-in Windows tasks sit under \Microsoft\Windows\; leave them alone unless you know what a task does. The same tasks are visible when you open Task Scheduler from the Start menu.

How to export/import scheduled tasks with PowerShell
Export-ScheduledTask returns the task definition as an XML string. Save it to a file, then feed it back to Register-ScheduledTask -Xml on the same or another computer.
- Export one task:
Export-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" | Out-File "C:\TaskBackup\WeeklyBackup.xml". - Export a whole folder, one file per task:
Get-ScheduledTask -TaskPath "\Scripts\" | ForEach-Object { Export-ScheduledTask -InputObject $_ | Out-File "C:\TaskBackup\$($_.TaskName).xml" }. - Copy the XML files to the target computer.
- Import a task:
Register-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" -Xml (Get-Content "C:\TaskBackup\WeeklyBackup.xml" -Raw). - If the task runs under a named account, add
-User "CONTOSO\svc-reports" -Password "<password>"to the import, because exported XML never carries the password.
-Raw matters: it hands -Xml one string instead of an array of lines. The same XML also imports through Import Task in the Task Scheduler window.
How to check when a scheduled task last ran in PowerShell
Get-ScheduledTaskInfo -TaskName "WeeklyBackup" -TaskPath "\Scripts\"
Get-ScheduledTask -TaskPath "\Scripts\" | Get-ScheduledTaskInfo
schtasks /query /tn "\Scripts\WeeklyBackup" /fo LIST /v
Line 1 shows the last run time, the last result code and the next run time for one task. Line 2 does the same for every task in the folder. Line 3 prints the full schedule, so you can confirm the recurrence is what you meant.
You should see: A last result of 0 means the last run succeeded, and a next run time in the future means the trigger is live. Any other number is a result code; look it up in the next table.
Scheduled task last run result codes (0x41301, 0x41303 and more)
PowerShell shows the last result as a decimal number. Convert it to the hex form Microsoft documents with '{0:X}' -f 267011, which returns 41303.
| Code | Decimal | Meaning |
|---|---|---|
| 0x0 | 0 | The last run finished successfully |
| 0x41300 | 267008 | The task is ready to run at its next scheduled time |
| 0x41301 | 267009 | The task is running right now |
| 0x41302 | 267010 | The task is disabled and will not run on schedule |
| 0x41303 | 267011 | The task has not run yet |
| 0x41306 | 267014 | The last run was stopped by a user |
| 0x4131C | 267036 | Registered, but the account needs the batch logon right to start it |
| 0x8004130F | -2147216625 | No account information stored for the task |
| 0x80041310 | -2147216624 | The run account could not be found |
| 0x80041315 | -2147216619 | The Task Scheduler service is not running |

Delete a scheduled task with Unregister-ScheduledTask
Unregister-ScheduledTask -TaskName "WeeklyBackup" -TaskPath "\Scripts\" -Confirm:$false
Removes the task from Task Scheduler. Without -Confirm:$false, PowerShell asks you to confirm first. Pipe a folder in, Get-ScheduledTask -TaskPath "\Scripts\" | Unregister-ScheduledTask, to remove every task in it.
You should see: Get-ScheduledTask -TaskName "WeeklyBackup" now returns an error saying no matching task was found.
Export the task first if you might want it back. Disable-ScheduledTask is the safer choice when you only need it to stop running for a while.
PowerShell scheduled task not running
The last result stays at 0x41303 and the task never starts
The trigger has not fired, the task is disabled, or a condition such as battery power is holding it back.
- Run
Get-ScheduledTask -TaskName "WeeklyBackup"and check that State is Ready, not Disabled. - Run
(Get-ScheduledTask -TaskName "WeeklyBackup").Triggersand check the start time and days. - On a laptop, apply a settings set with
-AllowStartIfOnBatteries -DontStopIfGoingOnBatteries. - Add
-StartWhenAvailableso a run missed while the PC was off starts as soon as it can.
The task reports success but the script did nothing
The script ran from C:\Windows\System32 or under an account that cannot reach its files.
- Add
-WorkingDirectoryto the action, or use full paths inside the script. - Check the
-Argumentstring:-Filemust come last, with the script path in quotes if it contains spaces. - If the script reads a network share, run the task under an account with a stored password, not S4U, which has no network access.
- Run the exact command line from the action in a PowerShell window under the same account to see the error.
The task stays on 0x41301 and never finishes
The script is waiting for input that never comes, or is stuck in a loop.
- Stop it with
Stop-ScheduledTask -TaskName "WeeklyBackup". - Add
-NonInteractiveto thepowershell.exearguments so prompts fail instead of waiting. - Set
-ExecutionTimeLimit (New-TimeSpan -Hours 1)in the settings so a hung run is ended automatically.
Result 0x80041310 or 0x8004130F after a password change
The task cannot find its account, or the stored credentials no longer match.
- Confirm the account name is spelled as
DOMAIN\userorPC\user. - Store the new password:
Set-ScheduledTask -TaskName "WeeklyBackup" -User "CONTOSO\svc-reports" -Password "<new password>". - Run
Start-ScheduledTaskand check the result again withGet-ScheduledTaskInfo.
If the job is simple and you prefer menus, the same task can be built in the graphical Task Scheduler in Windows 11 and 10 and then managed with these cmdlets.
PowerShell scheduled tasks FAQ
How do I list all scheduled tasks in PowerShell?
Run Get-ScheduledTask with no parameters to list every task with its folder, name and state. Add -TaskPath "\Scripts\*" to limit the list to one folder, or -TaskName "*Backup*" to match names with a wildcard.
How do I run a PowerShell script from Task Scheduler?
Set the action's program to powershell.exe and its arguments to -NoProfile -NonInteractive -File "C:\Scripts\script.ps1". -File must be the last parameter, and setting a working directory stops relative paths from resolving against System32.
How do I make a scheduled task repeat every few minutes in PowerShell?
Use a -Once trigger with repetition: New-ScheduledTaskTrigger -Once -At 8am -RepetitionInterval (New-TimeSpan -Minutes 5) -RepetitionDuration (New-TimeSpan -Days 1). Only the -Once parameter set accepts the repetition parameters.
Can New-ScheduledTaskTrigger create a monthly task?
No. New-ScheduledTaskTrigger supports once, daily, weekly, at startup and at logon only. Create monthly tasks with schtasks /create /sc monthly, which runs from a PowerShell prompt, then manage them with the ScheduledTasks cmdlets.
How do I run a scheduled task immediately with PowerShell?
Run Start-ScheduledTask -TaskName "TaskName", adding -TaskPath if the task is not in the root folder. The cmdlet starts the task and returns straight away, so check the outcome afterwards with Get-ScheduledTaskInfo.
How do I delete a scheduled task in PowerShell?
Run Unregister-ScheduledTask -TaskName "TaskName" -Confirm:$false. Leave out -Confirm:$false if you want PowerShell to ask before it deletes. Export the task with Export-ScheduledTask first if you may need it again.
Does Set-ScheduledTask change a task that is already running?
No. Set-ScheduledTask changes the stored task definition, and the instance that is already running carries on with the old definition. The changes apply from the next run.
What does 0x41301 mean for a scheduled task?
0x41301 means the task is currently running. If it never clears, the script is usually waiting for input or stuck; stop it with Stop-ScheduledTask and add -NonInteractive and an execution time limit.
Where does PowerShell put a new scheduled task?
In the root folder of the Task Scheduler Library unless you pass -TaskPath. The path must start and end with a backslash, for example -TaskPath "\Scripts\".





