---
layout: Reference
monikers:
- windowsserver2016-ps
defaultMoniker: windowsserver2025-ps
versioningType: Ranged
title: New-ScheduledTaskPrincipal (ScheduledTasks) | Microsoft Learn
canonicalUrl: https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps
config_moniker_range: WindowsServer2016-ps
uid: ScheduledTasks.New-ScheduledTaskPrincipal
module: ScheduledTasks
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
ROBOTS: INDEX, FOLLOW
apiPlatform: powershell
archive_url: https://learn.microsoft.com/previous-versions/powershell/windows/get-started
author: robinharwood
breadcrumb_path: /powershell/windows/bread/toc.json
feedback_product_url: https://support.microsoft.com/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332
feedback_system: Standard
manager: eliotgra
ms.author: roharwoo
ms.devlang: powershell
ms.service: windows-11
ms.topic: reference
uhfHeaderId: MSDocsHeader-M365-IT
products:
- https://authoring-docs-microsoft.poolparty.biz/devrel/56936876-97d9-45cc-ad1b-9d63320447c8
- https://authoring-docs-microsoft.poolparty.biz/devrel/ba9cbf34-2075-4eb6-8fe8-8a65dc77b667
- https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8
document type: cmdlet
external help file: PS_ScheduledTask_v1.0.cdxml-help.xml
HelpUri: https://learn.microsoft.com/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2016-ps&wt.mc_id=ps-gethelp
Module Name: ScheduledTasks
ms.date: 2016-12-20T00:00:00.0000000Z
PlatyPS schema version: 2024-05-01T00:00:00.0000000Z
locale: en-us
document_id: 9164b742-7bf1-4872-8183-fa5061ee617f
document_version_independent_id: 57bc659a-9971-ae7a-4df4-10c9c46d9ee3
updated_at: 2025-05-14T22:44:00.0000000Z
original_content_git_url: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/live/docset/winserver2016-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
gitcommit: https://github.com/MicrosoftDocs/windows-powershell-docs/blob/0ef3f225d29e26d1cf3119f37dfff70bb6165746/docset/winserver2016-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
git_commit_id: 0ef3f225d29e26d1cf3119f37dfff70bb6165746
default_moniker: windowsserver2025-ps
site_name: Docs
depot_name: TechNet.windows-powershell
in_right_rail: h2h3
page_type: powershell
page_kind: command
toc_rel: ../windowsserver2016-ps/toc.json
feedback_help_link_type: ''
feedback_help_link_url: ''
asset_id: module/scheduledtasks/new-scheduledtaskprincipal
moniker_range_name: b66907170add416803b0623a804b5a69
monikers:
- windowsserver2016-ps
item_type: Content
source_path: docset/winserver2016-ps/ScheduledTasks/New-ScheduledTaskPrincipal.md
cmProducts: []
spProducts:
- https://authoring-docs-microsoft.poolparty.biz/devrel/43b2e5aa-8a6d-4de2-a252-692232e5edc8
platformId: 217d14e4-c2eb-f8fa-f319-62e14d9d0179
---

# New-ScheduledTaskPrincipal

- Module:
    - [ScheduledTasks Module](./)

Creates an object that contains a scheduled task principal.

## Syntax

### User (Default)

```Syntax
New-ScheduledTaskPrincipal
    [[-Id] <String>]
    [[-RunLevel] <RunLevelEnum>]
    [[-ProcessTokenSidType] <ProcessTokenSidTypeEnum>]
    [[-RequiredPrivilege] <String[]>]
    [-UserId] <String>
    [[-LogonType] <LogonTypeEnum>]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]
```

### Group

```Syntax
New-ScheduledTaskPrincipal
    [-GroupId] <String>
    [[-Id] <String>]
    [[-RunLevel] <RunLevelEnum>]
    [[-ProcessTokenSidType] <ProcessTokenSidTypeEnum>]
    [[-RequiredPrivilege] <String[]>]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]
```

## Description

The **New-ScheduledTaskPrincipal** cmdlet creates an object that contains a scheduled task principal. Use a scheduled task principal to run a task under the security context of a specified account. When you use a scheduled task principal, Task Scheduler can run the task regardless of whether that account is logged on.

You can use the definition of a scheduled task principal to register a new scheduled task or update an existing task registration.

## Examples

### Example 1: Register a scheduled task by using a user ID for a task principal

```
PS C:\>$Sta = New-ScheduledTaskAction -Execute "Cmd"

The second command creates a scheduled task principal. The **New-ScheduledTaskPrincipal** cmdlet specifies that Task Scheduler uses the Local Service account to run tasks, and that the Local Service account uses the Service Account logon. The command assigns the **ScheduledTaskPrincipal** object to the $STPrin variable.
PS C:\>$STPrin = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount

The third command registers the scheduled task Task01 to run the task action named Cmd. The **Principal** parameter specifies that the Task Scheduler uses the Local Service account to run the task.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Principal $STPrin
```

This example registers a scheduled task that will run as the Local Service account.

The first command creates a scheduled task action named Cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.

### Example 2: Register a scheduled task by using a user group for a task principal

```
PS C:\>$Sta = New-ScheduledTaskAction cmd

The second command creates a scheduled task principal. The **New-ScheduledTaskPrincipal** cmdlet specifies that Task Scheduler uses the Administrators user group that has the highest privileges to run tasks. The command assigns the **ScheduledTaskPrincipal** object to the $STPrin variable.
PS C:\>$STPrin = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Administrators" -RunLevel Highest

The third command registers the scheduled task Task01 to run the task action named Cmd. The *Principal* parameter specifies that Task Scheduler uses the Administrators user group to run the task.
PS C:\>Register-ScheduledTask Task01 -Action $Sta -Principal $STPrin
```

This example registers a scheduled task that runs under logged-in members of the Administrators user group that has the highest privileges.

The first command creates a scheduled task action named cmd and assigns the **ScheduledTaskAction** object to the $Sta variable.

## Parameters

### -AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

#### Parameter properties

| Type: | SwitchParameter |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | Named |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a [New-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227967) or [Get-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227966) cmdlet. The default is the current session on the local computer.

#### Parameter properties

| Type: | CimSession[] |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Session |

#### Parameter sets

 (All) 

| Position: | Named |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -GroupId

Specifies the ID of a user group that Task Scheduler uses to run the tasks that are associated with the principal.

#### Parameter properties

| Type: | String |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 Group 

| Position: | 0 |
| --- | --- |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -Id

Specifies the ID of a scheduled task principal.

#### Parameter properties

| Type: | String |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | 5 |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -LogonType

Specifies the security logon method that Task Scheduler uses to run the tasks that are associated with the principal. The acceptable values for this parameter are:

- None
- Password
- S4U
- Interactive
- Group
- ServiceAccount
- InteractiveOrPassword

#### Parameter properties

| Type: | LogonTypeEnum |
| --- | --- |
| Default value: | None |
| Accepted values: | None, Password, S4U, Interactive, Group, ServiceAccount, InteractiveOrPassword |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 User 

| Position: | 1 |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -ProcessTokenSidType

Specifies the security ID (SID) type of the process token. The acceptable values for this parameter are:

- None
- Unrestricted
- Default

#### Parameter properties

| Type: | ProcessTokenSidTypeEnum |
| --- | --- |
| Default value: | None |
| Accepted values: | None, Unrestricted, Default |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | 3 |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -RequiredPrivilege

Specifies an array of user rights that Task Scheduler uses to run the tasks that are associated with the principal. Specify the constant name that is associated with a user right.

#### Parameter properties

| Type: | String[] |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | 4 |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -RunLevel

Specifies the level of user rights that Task Scheduler uses to run the tasks that are associated with the principal. The acceptable values for this parameter are:

- Highest. Tasks run by using the highest privileges.
- Limited. Tasks run by using the least-privileged user account (LUA).

#### Parameter properties

| Type: | RunLevelEnum |
| --- | --- |
| Default value: | None |
| Accepted values: | Limited, Highest |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | 2 |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -ThrottleLimit

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of `0` is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

#### Parameter properties

| Type: | Int32 |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 (All) 

| Position: | Named |
| --- | --- |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### -UserId

Specifies the user ID that Task Scheduler uses to run the tasks that are associated with the principal.

#### Parameter properties

| Type: | String |
| --- | --- |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |

#### Parameter sets

 User 

| Position: | 0 |
| --- | --- |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## Outputs

### [CimInstance](/en-us/dotnet/api/microsoft.management.infrastructure.ciminstance#MSFT_TaskPrincipal)

## Related Links

- [Get-ScheduledTaskInfo](get-scheduledtaskinfo)
- [New-ScheduledTaskAction](new-scheduledtaskaction)
- [New-ScheduledTaskSettingsSet](new-scheduledtasksettingsset)
- [New-ScheduledTaskTrigger](new-scheduledtasktrigger)
- [Register-ScheduledTask](register-scheduledtask)

---

## Other Supported Versions

- [windowsserver2019-ps](https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2019-ps&accept=text/markdown)
- [windowsserver2022-ps](https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2022-ps&accept=text/markdown)
- [windowsserver2025-ps](https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtaskprincipal?view=windowsserver2025-ps&accept=text/markdown)
