New-ScheduledTask

New-ScheduledTask

Creates a scheduled task instance.

構文

Parameter Set: New0
New-ScheduledTask [[-Action] <CimInstance[]> ] [[-Trigger] <CimInstance[]> ] [[-Settings] <CimInstance> ] [[-Principal] <CimInstance> ] [[-Description] <String> ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>]

詳細説明

The New-ScheduledTask cmdlet creates an object that contains the definition of a scheduled task. New-ScheduledTask does not automatically register the object with the Task Scheduler service.

You can register a task to run any of the following application or file types: Win32 applications, Win16 applications, OS/2 applications, MS-DOS applications, batch files (*.bat), command files (*.cmd), or any properly registered file type.

パラメーター

-Action<CimInstance[]>

Specifies an array of work items for a task to run. When you specify multiple actions, they run sequentially. A task can have up to 32 actions.

エイリアス

なし

必須?

false

位置は?

1

既定値

なし

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

false

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

false

-AsJob

エイリアス

なし

必須?

false

位置は?

named

既定値

なし

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

false

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

false

-CimSession<CimSession[]>

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

エイリアス

Session

必須?

false

位置は?

named

既定値

なし

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

false

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

false

-Description<String>

Briefly describes the task.

エイリアス

なし

必須?

false

位置は?

5

既定値

なし

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

false

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

false

-Principal<CimInstance>

Specifies the security context in which a task runs.

エイリアス

なし

必須?

false

位置は?

4

既定値

なし

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

false

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

false

-Settings<CimInstance>

Specifies a configuration object that the Task Scheduler service uses to determine how to run a task.

エイリアス

なし

必須?

false

位置は?

3

既定値

なし

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

false

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

false

-ThrottleLimit<Int32>

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

エイリアス

なし

必須?

false

位置は?

named

既定値

なし

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

false

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

false

-Trigger<CimInstance[]>

Specifies an array of one or more trigger objects that cause a scheduled task to start.

A trigger is a set of criteria that starts a scheduled task when the criteria are met. You can use a time-based trigger or an event-based trigger to start a task, and one or more triggers can start a task. A task can have up to 48 triggers. For more information about triggers, see Triggers.

エイリアス

なし

必須?

false

位置は?

2

既定値

なし

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

false

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

false

<CommonParameters>

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

入力

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

出力

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

  • Microsoft.Management.Infrastructure.CimInstance#MSFT_ScheduledTask

Example 1: Define a scheduled task and register it at a later time

In this example, the set of commands uses several cmdlets and variables to define and then register a scheduled task.

The first command uses the New-ScheduledTaskAction cmdlet to assign the variable $A to the executable file tskmgr.exe.

The second command uses the New-ScheduledTaskTrigger cmdlet to assign the variable $T to the value AtLogon.

The third command assigns the variable $P to the principal of the scheduled task, Contoso\Administrator.

The fourth command uses the New-ScheduledTaskSettingsSet cmdlet to assign the variable $S to a task settings object.

The fifth command creates a new task and assigns the variable $D to the task definition.

The sixth command (hypothetically) runs at a later time. It registers the new scheduled task and defines it by using the $D variable.

PS C:\> $A = New-ScheduledTaskAction –Execute "Taskmgr.exe"
PS C:\> $T = New-ScheduledTaskTrigger -AtLogon
PS C:\> $P = "Contoso\Administrator"
PS C:\> $S = New-ScheduledTaskSettingsSet
PS C:\> $D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S
PS C:\> Register-ScheduledTask T1 -InputObject $D

関連トピック

Get-ScheduledTask

Disable-ScheduledTask

Enable-ScheduledTask

Export-ScheduledTask

Register-ScheduledTask

Set-ScheduledTask

Start-ScheduledTask

Stop-ScheduledTask

Unregister-ScheduledTask

New-ScheduledTaskAction

New-ScheduledTaskSettingsSet

New-ScheduledTaskTrigger