New-ScheduledTaskPrincipal

New-ScheduledTaskPrincipal

Creates an object that contains a scheduled task principal.

構文

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>]

詳細説明

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.

パラメーター

-AsJob

エイリアス

なし

必須?

false

位置は?

named

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-CimSession<CimSession[]>

リモート セッションまたはリモート コンピューターでコマンドレットを実行します。New-CimSession コマンドレットや Get-CimSession コマンドレットの出力など、コンピューター名またはセッション オブジェクトを入力します。既定値は、ローカル コンピューターで実行中の現在のセッションです。

エイリアス

Session

必須?

false

位置は?

named

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-GroupId<String>

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

エイリアス

なし

必須?

true

位置は?

1

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-Id<String>

Specifies the ID of a scheduled task principal.

エイリアス

なし

必須?

false

位置は?

6

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-LogonType<LogonTypeEnum>

Specifies the security logon method that Task Scheduler uses to run the tasks that are associated with the principal. このパラメーターに対して使用できる値:
-- None
-- Password
-- S4U
-- Interactive
-- Group
-- ServiceAccount
-- Interactive or Password

エイリアス

なし

必須?

false

位置は?

2

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-ProcessTokenSidType<ProcessTokenSidTypeEnum>

Specifies the security ID (SID) type of the process token. このパラメーターに対して使用できる値:None, Unrestricted, and Default.

エイリアス

なし

必須?

false

位置は?

4

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

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.

エイリアス

なし

必須?

false

位置は?

4

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-RunLevel<RunLevelEnum>

Specifies the level of user rights that Task Scheduler uses to run the tasks that are associated with the principal. このパラメーターに対して使用できる値:
-- Highest: Tasks run by using the highest privileges.
-- LUA: Tasks run by using the least-privileged user account (LUA).

エイリアス

なし

必須?

false

位置は?

2

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-ThrottleLimit<Int32>

このコマンドレットを実行するために確立できる最大同時操作数を指定します。このパラメーターを省略するか、値として 0 を入力した場合、Windows PowerShell® では、コンピューターで実行している CIM コマンドレットの数に基づいて、コマンドレットに対する最適なスロットル制限を計算します。スロットル制限は現在のコマンドレットのみに適用され、セッションまたはコンピューターには適用されません。

エイリアス

なし

必須?

false

位置は?

named

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-UserId<String>

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

エイリアス

なし

必須?

true

位置は?

1

既定値

なし

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

<CommonParameters>

このコマンドレットは次の共通パラメーターをサポートします。-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、-OutVariable.詳細については、以下を参照してください。 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。

入力

入力型は、コマンドレットにパイプできるオブジェクトの型です。

出力

出力型は、コマンドレットによって生成されるオブジェクトの型です。

  • Microsoft.Management.Infrastructure.CimInstance#MSFT_TaskPrincipal

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

関連トピック

Register-ScheduledTask

Get-ScheduledTaskInfo

New-ScheduledTaskAction

New-ScheduledTaskSettingsSet

New-ScheduledTaskTrigger