Help us understand the problem. What is going on with this article?

Powershellでタスクスケジューラ登録

More than 1 year has passed since last update.

Powershellでタスクスケジュールを登録するためのメモ

深夜3時にIEを起動するだけのタスクスケジュールの登録です。
※下のUserがkotetsu75になっている2か所は適宜、お使いのユーザー名に変更してください。


$User = New-ScheduledTaskPrincipal -UserId kotetsu75 -LogonType Password
$Act = New-ScheduledTaskAction -Execute "C:\Program Files\internet explorer\iexplore.exe"
$Time = New-ScheduledTaskTrigger -Once -At 3am
$Task = New-ScheduledTask -Trigger $Time -Principal $User -Action $Act
Register-ScheduledTask -InputObject $Task -TaskName "test" -TaskPath \ -User kotetsu75

Linuxだとcronで超簡単にできるのに。。。

無効化するには

Disable-ScheduledTask test

有効化するには

Enable-ScheduledTask test

実行する

Start-ScheduledTask test

終了する

Stop-ScheduledTask test

補足:タスクスケジューラに関連するコマンド一覧表示

Get-Command | ? Name  -match "ScheduledTask"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Disable-ScheduledTask                              1.0.0.0    ScheduledTasks
Function        Enable-ScheduledTask                               1.0.0.0    ScheduledTasks
Function        Export-ScheduledTask                               1.0.0.0    ScheduledTasks
Function        Get-ClusteredScheduledTask                         1.0.0.0    ScheduledTasks
Function        Get-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        Get-ScheduledTaskInfo                              1.0.0.0    ScheduledTasks
Function        New-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskAction                            1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskPrincipal                         1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskSettingsSet                       1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskTrigger                           1.0.0.0    ScheduledTasks
Function        Register-ClusteredScheduledTask                    1.0.0.0    ScheduledTasks
Function        Register-ScheduledTask                             1.0.0.0    ScheduledTasks
Function        Set-ClusteredScheduledTask                         1.0.0.0    ScheduledTasks
Function        Set-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        Start-ScheduledTask                                1.0.0.0    ScheduledTasks
Function        Stop-ScheduledTask                                 1.0.0.0    ScheduledTasks
Function        Unregister-ClusteredScheduledTask                  1.0.0.0    ScheduledTasks
Function        Unregister-ScheduledTask                           1.0.0.0    ScheduledTasks
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away