PowerShell Genie

Register-ScheduledTask

Use Register-ScheduledTask to create a scheduled task from action, trigger, principal and settings objects.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — PowerShell module reference

Syntax

1PS> Register-ScheduledTask [-TaskName] <String> [-TaskPath <String>] [-Action <CimInstance[]>] [-Trigger <CimInstance[]>] [-Principal <CimInstance>] [-Settings <CimInstance>] [-User <String>] [-Password <String>] [-RunLevel <RunLevelEnum>] [-Force] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Register-ScheduledTask [-TaskName] <String> [-TaskPath <String>] [-Action <CimInstance[]>] [-Trigger <CimInstance[]>] [-Principal <CimInstance>] [-Settings <CimInstance>] [-User <String>] [-Password <String>] [-RunLevel <RunLevelEnum>] [-Force] [<CommonParameters>]
  1. Stage 1Register-ScheduledTask-TaskName -TaskPath -Action -Trigger -Principal -Settings -User -Password -RunLevel -Force

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Register-ScheduledTask -Execute pwsh.exe

    1PS> $action = New-ScheduledTaskAction -Execute pwsh.exe -Argument "-File C:\Scripts\Backup-Files.ps1"
    2PS> $trigger = New-ScheduledTaskTrigger -Daily -At 2am
    3PS> Register-ScheduledTask -TaskName Backup -Action $action -Trigger $trigger -RunLevel Highest
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TaskPath TaskName State
    -------- -------- -----
    \        Backup   Ready

    Register-ScheduledTask -Execute pwsh.exe (2)

    1PS> $action = New-ScheduledTaskAction -Execute pwsh.exe
    2PS> $t = New-ScheduledTaskTrigger -Daily -At 2am
    3PS> Register-ScheduledTask -TaskName Backup -Action $action -Trigger $t -RunLevel Highest
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TaskPath TaskName State
    -------- -------- -----
    \        Backup   Ready

    Register-ScheduledTask -UserId SYSTEM

    1PS> $p = New-ScheduledTaskPrincipal -UserId SYSTEM -LogonType ServiceAccount
    Show reference output

    Sample output · fictional data, shaped like the real thing

    TaskPath TaskName State
    -------- -------- -----
    \        Backup   Ready

    Parameters

    Parameter definitions:

    • -TaskName
    • -TaskPath
    • -Action
    • -Trigger
    • -Principal
    • -Settings
    • -User
    • -Password
    • -RunLevel
    • -Force

    PowerShell module reference on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Register-ScheduledTask when you need to create a scheduled task from action, trigger, principal and settings objects. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: A task that registers but fails later may use a missing executable or incorrect working directory. Supply an absolute action path and inspect its runtime result under the task's configured account. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Get-ScheduledTask. Register-ScheduledTask registers a task definition; Get-ScheduledTask reads the registered configuration. Review the action, principal and trigger as separate parts of the task. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Register-ScheduledTask reference on Microsoft Learn

    Recap

    Register-ScheduledTask Use Register-ScheduledTask to create a scheduled task from action, trigger, principal and settings objects.

    Next: Start-ScheduledTask
    Genie guideRegister-ScheduledTask

    Use Register-ScheduledTask to create a scheduled task from action, trigger, principal and settings objects. The console below is pre-loaded — run it, then change a value and run it again.