New-ScheduledTaskPrincipal

New-ScheduledTaskPrincipal

Creates an object that contains a scheduled task principal.

Syntax

Parameter Set: User
New-ScheduledTaskPrincipal [-UserId] <String> [[-LogonType] <LogonTypeEnum> ] [[-RunLevel] <RunLevelEnum> ] [[-ProcessTokenSidType] <ProcessTokenSidTypeEnum> ] [[-RequiredPrivilege] <String[]> ] [[-Id] <String> ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Parameter Set: Group
New-ScheduledTaskPrincipal [-GroupId] <String> [[-RunLevel] <RunLevelEnum> ] [[-ProcessTokenSidType] <ProcessTokenSidTypeEnum> ] [[-RequiredPrivilege] <String[]> ] [[-Id] <String> ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

Detaillierte Beschreibung

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.

Parameter

-AsJob

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-CimSession<CimSession[]>

Führt das Cmdlet in einer Remotesitzung oder auf einem Remotecomputer aus. Geben Sie einen Computernamen oder ein Sitzungsobjekt ein, z. B. die Ausgabe eines Cmdlets New-CimSession oder Get-CimSession. Der Standardwert ist die aktuelle Sitzung auf dem lokalen Computer.

Aliasse

Session

Erforderlich?

false

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-GroupId<String>

Specifies the ID of a user group that Task Scheduler uses to run the tasks that are associated with the principal.

Aliasse

Keiner

Erforderlich?

true

Position?

1

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Id<String>

Specifies the ID of a scheduled task principal.

Aliasse

Keiner

Erforderlich?

false

Position?

6

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-LogonType<LogonTypeEnum>

Specifies the security logon method that Task Scheduler uses to run the tasks that are associated with the principal. Die folgenden Werte für diesen Parameter sind zulässig:
-- None
-- Password
-- S4U
-- Interactive
-- Group
-- ServiceAccount
-- Interactive or Password

Aliasse

Keiner

Erforderlich?

false

Position?

2

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-ProcessTokenSidType<ProcessTokenSidTypeEnum>

Specifies the security ID (SID) type of the process token. Die folgenden Werte für diesen Parameter sind zulässig:None, Unrestricted, and Default.

Aliasse

Keiner

Erforderlich?

false

Position?

4

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-RequiredPrivilege<String[]>

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.

Aliasse

Keiner

Erforderlich?

false

Position?

4

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-RunLevel<RunLevelEnum>

Specifies the level of user rights that Task Scheduler uses to run the tasks that are associated with the principal. Die folgenden Werte für diesen Parameter sind zulässig:
-- Highest: Tasks run by using the highest privileges.
-- LUA: Tasks run by using the least-privileged user account (LUA).

Aliasse

Keiner

Erforderlich?

false

Position?

2

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-ThrottleLimit<Int32>

Gibt die maximale Anzahl von gleichzeitigen Vorgängen an, die zum Ausführen dieses Cmdlets eingerichtet werden können. Wenn dieser Parameter ausgelassen oder der Wert 0 eingegeben wird, berechnet Windows PowerShell® einen optimalen Drosselungsgrenzwert für das Cmdlet basierend auf der Anzahl der CIM-Cmdlets, die auf dem Computer ausgeführt werden. Die Drosselungsgrenze gilt nur für das aktuelle Cmdlet und nicht für die Sitzung oder den Computer.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-UserId<String>

Specifies the user ID that Task Scheduler uses to run the tasks that are associated with the principal.

Aliasse

Keiner

Erforderlich?

true

Position?

1

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

<CommonParameters>

Dieses Cmdlet unterstützt die allgemeinen Parameter: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable. Weitere Informationen finden Sie unter about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Eingaben

Der Eingabetyp ist der Typ der Objekte, die über die Pipeline an das Cmdlet übergeben werden können.

Ausgaben

Der Ausgabetyp ist der Typ der Objekte, die vom Cmdlet ausgegeben werden.

  • Microsoft.Management.Infrastructure.CimInstance#MSFT_TaskPrincipal

Beispiele

Example 1: Register a scheduled task by using a user ID for a task principal

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.

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 $a -Principal $p

Example 2: Register a scheduled task by using a user group for a task principal

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.

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

Verwandte Themen

Register-ScheduledTask

Get-ScheduledTaskInfo

New-ScheduledTaskAction

New-ScheduledTaskSettingsSet

New-ScheduledTaskTrigger